mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Issue #7367: Fix pkgutil.walk_paths to skip directories whose
contents cannot be read.
This commit is contained in:
parent
caf5a22c5f
commit
ed27df7aaa
1 changed files with 11 additions and 3 deletions
|
@ -191,8 +191,11 @@ class ImpImporter:
|
||||||
|
|
||||||
yielded = {}
|
yielded = {}
|
||||||
import inspect
|
import inspect
|
||||||
|
try:
|
||||||
filenames = os.listdir(self.path)
|
filenames = os.listdir(self.path)
|
||||||
|
except OSError:
|
||||||
|
# ignore unreadable directories like import does
|
||||||
|
filenames = []
|
||||||
filenames.sort() # handle packages before same-named modules
|
filenames.sort() # handle packages before same-named modules
|
||||||
|
|
||||||
for fn in filenames:
|
for fn in filenames:
|
||||||
|
@ -205,7 +208,12 @@ class ImpImporter:
|
||||||
|
|
||||||
if not modname and os.path.isdir(path) and '.' not in fn:
|
if not modname and os.path.isdir(path) and '.' not in fn:
|
||||||
modname = 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)
|
subname = inspect.getmodulename(fn)
|
||||||
if subname=='__init__':
|
if subname=='__init__':
|
||||||
ispkg = True
|
ispkg = True
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue