]> granicus.if.org Git - python/commitdiff
Add Py3k warnings to os.path.walk
authorBenjamin Peterson <benjamin@python.org>
Fri, 9 May 2008 00:27:01 +0000 (00:27 +0000)
committerBenjamin Peterson <benjamin@python.org>
Fri, 9 May 2008 00:27:01 +0000 (00:27 +0000)
Doc/library/os.path.rst
Lib/macpath.py
Lib/ntpath.py
Lib/posixpath.py
Lib/test/test_py3kwarn.py
Misc/NEWS

index fa6b0c0f40c7780e70c1e3977e9480f45ec691cf..58a5caf489b93bd0a5b6a5d3bada84f35f96db52 100644 (file)
@@ -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
index f54ffa07d71a654c4d252249384e52834efcdbf2..38e6eaeda9163c71388c1bb7a12889eb7bef9701 100644 (file)
@@ -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:
index 59f1402288b893fa831a48bc477a15637faed177..714f2054161ed2b731be7a57f3cb502d56ee1d34 100644 (file)
@@ -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:
index ee6d0f2407ab8e09d8ba9cda0a1c404e4df3de0e..9fa53d0062e644b827cbb0a1b27426a5dd54bb7e 100644 (file)
@@ -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:
index ab8e3168bdd185fbaa999e9ea4f53602f32b7655..dd7c765025cb98c685c15f02c539b0c613957192 100644 (file)
@@ -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)
index 5c7d304c53aa6d0729f2a3014e7ae9104f154e6a..a4f886b36fcf1c379b60cc13150192c4868d8c88 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -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
 -----