mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
Add Py3k warnings to os.path.walk
This commit is contained in:
parent
9ec4aa01f9
commit
0893a0a961
6 changed files with 23 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
-----
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue