[Python-checkins] cpython (3.2): Issue #7367: Fix pkgutil.walk_paths to skip directories whose
ned.deily
python-checkins at python.org
Thu Oct 6 23:43:12 CEST 2011
http://hg.python.org/cpython/rev/77bac85f610a
changeset: 72774:77bac85f610a
branch: 3.2
user: Ned Deily <nad at acm.org>
date: Thu Oct 06 14:19:08 2011 -0700
summary:
Issue #7367: Fix pkgutil.walk_paths to skip directories whose
contents cannot be read.
files:
Lib/pkgutil.py | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/Lib/pkgutil.py b/Lib/pkgutil.py
--- a/Lib/pkgutil.py
+++ b/Lib/pkgutil.py
@@ -191,8 +191,11 @@
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 @@
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
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list