diff options
author | Ned Deily <nad@acm.org> | 2011-10-06 21:19:08 (GMT) |
---|---|---|
committer | Ned Deily <nad@acm.org> | 2011-10-06 21:19:08 (GMT) |
commit | ed27df7aaa844d124d8ee25aa93ef74dfac5b191 (patch) | |
tree | 705ee4ea3d032034e66e5aa2170fc95801999f17 /Lib | |
parent | caf5a22c5f864c21d1c13a5aa39986f85e89994d (diff) | |
download | cpython-ed27df7aaa844d124d8ee25aa93ef74dfac5b191.zip cpython-ed27df7aaa844d124d8ee25aa93ef74dfac5b191.tar.gz cpython-ed27df7aaa844d124d8ee25aa93ef74dfac5b191.tar.bz2 |
Issue #7367: Fix pkgutil.walk_paths to skip directories whose
contents cannot be read.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/pkgutil.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/Lib/pkgutil.py b/Lib/pkgutil.py index 2d88568..51da0b1 100644 --- a/Lib/pkgutil.py +++ b/Lib/pkgutil.py @@ -191,8 +191,11 @@ class ImpImporter: yielded = {} import inspect - - filenames = os.listdir(self.path) + try: + filenames = os.listdir(self.path) + except OSError: + # ignore unreadable directories like import does + filenames = [] filenames.sort() # handle packages before same-named modules for fn in filenames: @@ -205,7 +208,12 @@ class ImpImporter: if not modname and os.path.isdir(path) and '.' not in fn: modname = fn - for fn in os.listdir(path): + try: + dircontents = os.listdir(path) + except OSError: + # ignore unreadable directories like import does + dircontents = [] + for fn in dircontents: subname = inspect.getmodulename(fn) if subname=='__init__': ispkg = True |