summaryrefslogtreecommitdiff
path: root/sphinx/util/osutil.py
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2018-09-23 08:04:57 -0700
committerJon Dufresne <jon.dufresne@gmail.com>2018-10-05 12:39:50 -0700
commit05ac246effc71bbab55eb850f37211dd83245c21 (patch)
tree88f0748b6ba7738af3ba97829058ad573253e162 /sphinx/util/osutil.py
parentc206c02a57e70429f39c38953f56df05c47718f8 (diff)
downloadsphinx-git-05ac246effc71bbab55eb850f37211dd83245c21.tar.gz
Deprecate Python2 compat shim sphinx.util.osutil.walk()
Code should use os.walk() instead, which works with either str or bytes. All internal calls use str.
Diffstat (limited to 'sphinx/util/osutil.py')
-rw-r--r--sphinx/util/osutil.py35
1 files changed, 4 insertions, 31 deletions
diff --git a/sphinx/util/osutil.py b/sphinx/util/osutil.py
index 38a986f6b..11b082e7d 100644
--- a/sphinx/util/osutil.py
+++ b/sphinx/util/osutil.py
@@ -90,39 +90,12 @@ def ensuredir(path):
raise
-# This function is same as os.walk of Python2.7 except a customization
-# that check UnicodeError.
-# The customization obstacle to replace the function with the os.walk.
def walk(top, topdown=True, followlinks=False):
# type: (unicode, bool, bool) -> Iterator[Tuple[unicode, List[unicode], List[unicode]]]
- """Backport of os.walk from 2.6, where the *followlinks* argument was
- added.
- """
- names = os.listdir(top)
-
- dirs, nondirs = [], []
- for name in names:
- try:
- fullpath = path.join(top, name)
- except UnicodeError:
- print('%s:: ERROR: non-ASCII filename not supported on this '
- 'filesystem encoding %r, skipped.' % (name, fs_encoding),
- file=sys.stderr)
- continue
- if path.isdir(fullpath):
- dirs.append(name)
- else:
- nondirs.append(name)
-
- if topdown:
- yield top, dirs, nondirs
- for name in dirs:
- fullpath = path.join(top, name)
- if followlinks or not path.islink(fullpath):
- for x in walk(fullpath, topdown, followlinks):
- yield x
- if not topdown:
- yield top, dirs, nondirs
+ warnings.warn('sphinx.util.osutil.walk() is deprecated for removal. '
+ 'Please use os.walk() instead.',
+ RemovedInSphinx40Warning)
+ return os.walk(top, topdown=topdown, followlinks=followlinks)
def mtimes_of_files(dirnames, suffix):