[Python-checkins] cpython (3.5): Fix pyclbr to support importing packages
victor.stinner
python-checkins at python.org
Thu Mar 17 04:12:33 EDT 2016
https://hg.python.org/cpython/rev/700ae1bfc453
changeset: 100571:700ae1bfc453
branch: 3.5
parent: 100569:0774398c3433
user: Victor Stinner <victor.stinner at gmail.com>
date: Thu Mar 17 09:06:41 2016 +0100
summary:
Fix pyclbr to support importing packages
Issue #26569: Fix pyclbr.readmodule() and pyclbr.readmodule_ex() to support
importing packages.
files:
Lib/pyclbr.py | 8 +++++---
Misc/NEWS | 3 +++
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/Lib/pyclbr.py b/Lib/pyclbr.py
--- a/Lib/pyclbr.py
+++ b/Lib/pyclbr.py
@@ -142,10 +142,10 @@
search_path = path + sys.path
# XXX This will change once issue19944 lands.
spec = importlib.util._find_spec_from_path(fullmodule, search_path)
- fname = spec.loader.get_filename(fullmodule)
_modules[fullmodule] = dict
- if spec.loader.is_package(fullmodule):
- dict['__path__'] = [os.path.dirname(fname)]
+ # is module a package?
+ if spec.submodule_search_locations is not None:
+ dict['__path__'] = spec.submodule_search_locations
try:
source = spec.loader.get_source(fullmodule)
if source is None:
@@ -154,6 +154,8 @@
# not Python source, can't do anything with this module
return dict
+ fname = spec.loader.get_filename(fullmodule)
+
f = io.StringIO(source)
stack = [] # stack of (class, indent) pairs
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -91,6 +91,9 @@
Library
-------
+- Issue #26569: Fix :func:`pyclbr.readmodule` and :func:`pyclbr.readmodule_ex`
+ to support importing packages.
+
- Issue #26499: Account for remaining Content-Length in
HTTPResponse.readline() and read1(). Based on patch by Silent Ghost.
Also document that HTTPResponse now supports these methods.
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list