New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SystemError: <built-in function create_builtin> returned NULL without setting an error
from importing _pickle on Windows
#75056
Comments
The following rather long code, reduced from the same example as bpo-30626, produces a SystemError: import builtins
from importlib.machinery import PathFinder
import importlib
import sys
import _imp
from functools import partial
def copy_module(module):
new = type(sys)(module.__name__)
new.__dict__.update(module.__dict__)
return new
_absent = object()
def new_exec(code, globals=_absent, locals=_absent, *, new_builtins):
if globals == _absent:
frame = sys._getframe(2)
globals = frame.f_globals
locals = frame.f_locals
elif locals == _absent:
locals = globals
globals.setdefault("__builtins__", new_builtins);
return exec(code, globals, locals)
dct={}
dct["__builtins__"] = b = copy_module(builtins)
b.exec = partial(new_exec, new_builtins=b)
spec = PathFinder.find_spec("_bootstrap",importlib.__path__)
source_bootstrap = type(sys)("_bootstrap");
spec.loader.exec_module(source_bootstrap);
external_spec = PathFinder.find_spec("_bootstrap_external",importlib.__path__)
source_bootstrap_external = type(sys)("_bootstrap_external");
external_spec.loader.exec_module(source_bootstrap_external);
source_bootstrap.__name__ = "importlib._bootstrap";
source_bootstrap_external.__name__ = "importlib._bootstrap_external";
new_sys = copy_module(sys)
new_sys.path_importer_cache = {}
new_sys.path_hooks = []
new_sys.meta_path = []
new_sys.modules = {
"importlib._bootstrap":source_bootstrap,
"importlib._bootstrap_external":source_bootstrap_external,
}
for mod in new_sys.modules.values():
mod.__builtins__ = b
b.__import__ = source_bootstrap.__import__
source_bootstrap._install(new_sys,_imp)
exec("import _pickle", dct) |
SystemError: <built-in function create_builtin> returned NULL without setting an error
from imp.create_builtinSystemError: <built-in function create_builtin> returned NULL without setting an error
from importing _pickle
I get the following error on 3.7: $ ./python issue30873.py
Traceback (most recent call last):
File "issue30873.py", line 44, in <module>
exec("import _pickle", dct)
File "<string>", line 1, in <module>
File "/home/serhiy/py/cpython/Lib/importlib/_bootstrap.py", line 1059, in __import__
module = _gcd_import(name)
File "/home/serhiy/py/cpython/Lib/importlib/_bootstrap.py", line 986, in _gcd_import
return _find_and_load(name, _gcd_import)
File "/home/serhiy/py/cpython/Lib/importlib/_bootstrap.py", line 963, in _find_and_load
return _find_and_load_unlocked(name, import_)
File "/home/serhiy/py/cpython/Lib/importlib/_bootstrap.py", line 948, in _find_and_load_unlocked
raise ModuleNotFoundError(_ERR_MSG.format(name), name=name)
ModuleNotFoundError: No module named '_pickle' On 3.6: $ ./python issue30873.py
Traceback (most recent call last):
File "issue30873.py", line 44, in <module>
exec("import _pickle", dct)
File "<string>", line 1, in <module>
File "/home/serhiy/py/cpython3.6/Lib/importlib/_bootstrap.py", line 1059, in __import__
module = _gcd_import(name)
File "/home/serhiy/py/cpython3.6/Lib/importlib/_bootstrap.py", line 986, in _gcd_import
return _find_and_load(name, _gcd_import)
File "/home/serhiy/py/cpython3.6/Lib/importlib/_bootstrap.py", line 963, in _find_and_load
return _find_and_load_unlocked(name, import_)
File "/home/serhiy/py/cpython3.6/Lib/importlib/_bootstrap.py", line 950, in _find_and_load_unlocked
module = _load_unlocked(spec)
File "/home/serhiy/py/cpython3.6/Lib/importlib/_bootstrap.py", line 648, in _load_unlocked
module = module_from_spec(spec)
File "/home/serhiy/py/cpython3.6/Lib/importlib/_bootstrap.py", line 560, in module_from_spec
module = spec.loader.create_module(spec)
File "<frozen importlib._bootstrap_external>", line 922, in create_module
File "/home/serhiy/py/cpython3.6/Lib/importlib/_bootstrap.py", line 205, in _call_with_frames_removed
return f(*args, **kwds)
KeyError: 'copyreg' |
Interesting. For you, |
Ah, this is Windows-only _imp.create_builtin(). |
SystemError: <built-in function create_builtin> returned NULL without setting an error
from importing _pickleSystemError: <built-in function create_builtin> returned NULL without setting an error
from importing _pickle on Windows
ppperry: First, please create a Python script and attach it to the issue, it would make it easier to reproduce the bug. Second, which Python version did you test? I tested 3.6 and master Git branches on Windows, and I'm unable to reproduce the bug. I'm able to reproduce the bug on Windows using Python 3.6.1, but this version still contains bpo-30626 bug. I'm unable to reproduce the bug using 3.6.2rc2, so to be, this bug is just a duplicate of bpo-30626. Please try: https://www.python.org/downloads/release/python-362rc2/ |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: