summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/_bootstrap.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2012-09-29 07:27:15 (GMT)
committerGeorg Brandl <georg@python.org>2012-09-29 07:27:15 (GMT)
commit99a247fd01c1cd780c0c3ee1116657627f1ee744 (patch)
tree319e33cb6612c3fafb2eb82e15c5e85e3d771e4f /Lib/importlib/_bootstrap.py
parent1628eaa5dc8892ff381ca7558cc7c8d80fac494d (diff)
parent8ed677db129171317b8ee7cd45b39b9013f5a2d6 (diff)
downloadcpython-99a247fd01c1cd780c0c3ee1116657627f1ee744.zip
cpython-99a247fd01c1cd780c0c3ee1116657627f1ee744.tar.gz
cpython-99a247fd01c1cd780c0c3ee1116657627f1ee744.tar.bz2
Merge with main repo default branch.
Diffstat (limited to 'Lib/importlib/_bootstrap.py')
-rw-r--r--Lib/importlib/_bootstrap.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index 5c4d2c6..98361a7 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -419,8 +419,8 @@ def cache_from_source(path, debug_override=None):
.pyc/.pyo file calculated as if the .py file were imported. The extension
will be .pyc unless sys.flags.optimize is non-zero, then it will be .pyo.
- If debug_override is not None, then it must be a boolean and is taken as
- the value of bool(sys.flags.optimize) instead.
+ If debug_override is not None, then it must be a boolean and is used in
+ place of sys.flags.optimize.
If sys.implementation.cache_tag is None then NotImplementedError is raised.
@@ -1669,7 +1669,11 @@ def __import__(name, globals=None, locals=None, fromlist=(), level=0):
elif not name:
return module
else:
+ # Figure out where to slice the module's name up to the first dot
+ # in 'name'.
cut_off = len(name) - len(name.partition('.')[0])
+ # Slice end needs to be positive to alleviate need to special-case
+ # when ``'.' not in name``.
return sys.modules[module.__name__[:len(module.__name__)-cut_off]]
else:
return _handle_fromlist(module, fromlist, _gcd_import)