summaryrefslogtreecommitdiffstats
path: root/Lib/runpy.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2012-07-14 14:07:43 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2012-07-14 14:07:43 (GMT)
commit2f54b98c8c40ab2190db59ae66d23f795b92daa2 (patch)
tree488223e2d14f7495a9ae9d27cfbdfceda77def25 /Lib/runpy.py
parent045bd5340f437468e30d7880700f241ed6830010 (diff)
parent761bb1137445c75c4ba87d3669dd546e25277cd5 (diff)
downloadcpython-2f54b98c8c40ab2190db59ae66d23f795b92daa2.zip
cpython-2f54b98c8c40ab2190db59ae66d23f795b92daa2.tar.gz
cpython-2f54b98c8c40ab2190db59ae66d23f795b92daa2.tar.bz2
Merge fix for #15230 from 3.2
Diffstat (limited to 'Lib/runpy.py')
-rw-r--r--Lib/runpy.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/runpy.py b/Lib/runpy.py
index 71c175f..8ca325b 100644
--- a/Lib/runpy.py
+++ b/Lib/runpy.py
@@ -70,6 +70,7 @@ def _run_code(code, run_globals, init_globals=None,
run_globals.update(__name__ = mod_name,
__file__ = mod_fname,
__cached__ = None,
+ __doc__ = None,
__loader__ = mod_loader,
__package__ = pkg_name)
exec(code, run_globals)
@@ -233,12 +234,14 @@ def run_path(path_name, init_globals=None, run_name=None):
"""
if run_name is None:
run_name = "<run_path>"
+ pkg_name = run_name.rpartition(".")[0]
importer = _get_importer(path_name)
if isinstance(importer, (type(None), imp.NullImporter)):
# Not a valid sys.path entry, so run the code directly
# execfile() doesn't help as we want to allow compiled files
code = _get_code_from_file(path_name)
- return _run_module_code(code, init_globals, run_name, path_name)
+ return _run_module_code(code, init_globals, run_name, path_name,
+ pkg_name=pkg_name)
else:
# Importer is defined for path, so add it to
# the start of sys.path
@@ -257,7 +260,6 @@ def run_path(path_name, init_globals=None, run_name=None):
mod_name, loader, code, fname = _get_main_module_details()
finally:
sys.modules[main_name] = saved_main
- pkg_name = ""
with _TempModule(run_name) as temp_module, \
_ModifiedArgv0(path_name):
mod_globals = temp_module.module.__dict__