[pypy-commit] pypy py3.6: Issue #3034
arigo
pypy.commits at gmail.com
Thu Aug 1 11:08:32 EDT 2019
Author: Armin Rigo <arigo at tunes.org>
Branch: py3.6
Changeset: r97041:ad5f870b5e2e
Date: 2019-08-01 17:07 +0200
http://bitbucket.org/pypy/pypy/changeset/ad5f870b5e2e/
Log: Issue #3034
Fix inside this code path of the import logic, which is not used any
more except of course when it is (by zipimport only)
diff --git a/pypy/module/imp/importing.py b/pypy/module/imp/importing.py
--- a/pypy/module/imp/importing.py
+++ b/pypy/module/imp/importing.py
@@ -266,6 +266,20 @@
w_cpathname = space.w_None
space.setitem(w_dict, space.newtext("__file__"), w_pathname)
space.setitem(w_dict, space.newtext("__cached__"), w_cpathname)
+ #
+ # like PyImport_ExecCodeModuleObject(), we invoke
+ # _bootstrap_external._fix_up_module() here, which should try to
+ # fix a few more attributes (also __file__ and __cached__, but
+ # let's keep the logic that also sets them explicitly above, just
+ # in case)
+ space.appexec([w_dict, w_pathname, w_cpathname],
+ """(d, pathname, cpathname):
+ from importlib._bootstrap_external import _fix_up_module
+ name = d.get('__name__')
+ if name is not None:
+ _fix_up_module(d, name, pathname, cpathname)
+ """)
+ #
code_w.exec_code(space, w_dict, w_dict)
def rightmost_sep(filename):
diff --git a/pypy/module/zipimport/test/test_zipimport.py b/pypy/module/zipimport/test/test_zipimport.py
--- a/pypy/module/zipimport/test/test_zipimport.py
+++ b/pypy/module/zipimport/test/test_zipimport.py
@@ -462,6 +462,11 @@
foo = __import__('foo.bar.one', None, None, [])
assert foo.bar.one.attr == 'portion1 foo one'
+ def test___spec__(self):
+ self.writefile('uvwv.py', 'spec = __spec__')
+ mod = __import__('uvwv', globals(), locals(), [])
+ assert mod.spec is not None
+
if os.sep != '/':
class AppTestNativePathSep(AppTestZipimport):
More information about the pypy-commit
mailing list