diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-05-09 00:27:01 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-05-09 00:27:01 (GMT) |
commit | 0893a0a961c3393aea052b268b630a7e522ba3a9 (patch) | |
tree | 4b1535bcb1f2be754a8de5a711742c3574ab5438 | |
parent | 9ec4aa01f9e1b5f0d8ed94005ac5b14d6ff94ebc (diff) | |
download | cpython-0893a0a961c3393aea052b268b630a7e522ba3a9.zip cpython-0893a0a961c3393aea052b268b630a7e522ba3a9.tar.gz cpython-0893a0a961c3393aea052b268b630a7e522ba3a9.tar.bz2 |
Add Py3k warnings to os.path.walk
-rw-r--r-- | Doc/library/os.path.rst | 6 | ||||
-rw-r--r-- | Lib/macpath.py | 3 | ||||
-rw-r--r-- | Lib/ntpath.py | 4 | ||||
-rw-r--r-- | Lib/posixpath.py | 3 | ||||
-rw-r--r-- | Lib/test/test_py3kwarn.py | 11 | ||||
-rw-r--r-- | Misc/NEWS | 2 |
6 files changed, 23 insertions, 6 deletions
diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst index fa6b0c0..58a5caf 100644 --- a/Doc/library/os.path.rst +++ b/Doc/library/os.path.rst @@ -303,10 +303,10 @@ write files see :func:`open`, and for accessing the filesystem see the identify them with ``os.path.islink(file)`` and ``os.path.isdir(file)``, and invoke :func:`walk` as necessary. - .. note:: + .. warning:: - The newer :func:`os.walk` :term:`generator` supplies similar functionality - and can be easier to use. + This function is deprecated and is removed in 3.0 in favor of + :func:`os.walk`. .. data:: supports_unicode_filenames diff --git a/Lib/macpath.py b/Lib/macpath.py index f54ffa0..38e6eae 100644 --- a/Lib/macpath.py +++ b/Lib/macpath.py @@ -1,6 +1,7 @@ """Pathname and path-related operations for the Macintosh.""" import os +import warnings from stat import * import genericpath from genericpath import * @@ -169,7 +170,7 @@ def walk(top, func, arg): beyond that arg is always passed to func. It can be used, e.g., to pass a filename pattern, or a mutable object designed to accumulate statistics. Passing None for arg is common.""" - + warnings.warnpy3k("In 3.x, os.path.walk is removed in favor of os.walk.") try: names = os.listdir(top) except os.error: diff --git a/Lib/ntpath.py b/Lib/ntpath.py index 59f1402..714f205 100644 --- a/Lib/ntpath.py +++ b/Lib/ntpath.py @@ -9,6 +9,8 @@ import os import sys import stat import genericpath +import warnings + from genericpath import * __all__ = ["normcase","isabs","join","splitdrive","split","splitext", @@ -248,7 +250,7 @@ def walk(top, func, arg): beyond that arg is always passed to func. It can be used, e.g., to pass a filename pattern, or a mutable object designed to accumulate statistics. Passing None for arg is common.""" - + warnings.warnpy3k("In 3.x, os.path.walk is removed in favor of os.walk.") try: names = os.listdir(top) except os.error: diff --git a/Lib/posixpath.py b/Lib/posixpath.py index ee6d0f2..9fa53d0 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -13,6 +13,7 @@ for manipulation of the pathname component of URLs. import os import stat import genericpath +import warnings from genericpath import * __all__ = ["normcase","isabs","join","splitdrive","split","splitext", @@ -215,7 +216,7 @@ def walk(top, func, arg): beyond that arg is always passed to func. It can be used, e.g., to pass a filename pattern, or a mutable object designed to accumulate statistics. Passing None for arg is common.""" - + warnings.warnpy3k("In 3.x, os.path.walk is removed in favor of os.walk.") try: names = os.listdir(top) except os.error: diff --git a/Lib/test/test_py3kwarn.py b/Lib/test/test_py3kwarn.py index ab8e316..dd7c765 100644 --- a/Lib/test/test_py3kwarn.py +++ b/Lib/test/test_py3kwarn.py @@ -157,6 +157,17 @@ class TestStdlibRemovals(unittest.TestCase): for module_name in self.all_platforms: self.check_removal(module_name) + def test_os_path_walk(self): + msg = "In 3.x, os.path.walk is removed in favor of os.walk." + def dumbo(where, names, args): pass + for path_mod in ("ntpath", "macpath", "os2emxpath", "posixpath"): + mod = __import__(path_mod) + with catch_warning() as w: + # Since os3exmpath just imports it from ntpath + warnings.simplefilter("always") + mod.walk(".", dumbo, None) + self.assertEquals(str(w.message), msg) + def test_main(): run_unittest(TestPy3KWarnings, TestStdlibRemovals) @@ -30,6 +30,8 @@ Library - test.test_support.catch_warning() gained a 'record' argument. +- os.path.walk is deprecated in favor of os.walk. + Build ----- |