summaryrefslogtreecommitdiffstats
path: root/Lib/pkgutil.py
diff options
context:
space:
mode:
authorNed Deily <nad@acm.org>2011-10-06 21:24:31 (GMT)
committerNed Deily <nad@acm.org>2011-10-06 21:24:31 (GMT)
commit94030712770513a26bbe80346168b340dc6a16f3 (patch)
treec914f1293ea51c570b92b7450849ecd1316f0e6d /Lib/pkgutil.py
parent17a332ac1b6206a42e6a737dc7d995e5fcffdcba (diff)
parented27df7aaa844d124d8ee25aa93ef74dfac5b191 (diff)
downloadcpython-94030712770513a26bbe80346168b340dc6a16f3.zip
cpython-94030712770513a26bbe80346168b340dc6a16f3.tar.gz
cpython-94030712770513a26bbe80346168b340dc6a16f3.tar.bz2
merge from 3.2
Diffstat (limited to 'Lib/pkgutil.py')
-rw-r--r--Lib/pkgutil.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/Lib/pkgutil.py b/Lib/pkgutil.py
index c561c13..bdea23e 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