[issue30626] "SystemError: SystemError: <class '_io.TextIOWrapper'> returned NULL without setting an error" from open function
ppperry
report at bugs.python.org
Sat Jun 10 14:57:30 EDT 2017
New submission from ppperry:
This code (reduced from an example I had of trying to debug code including the module-level code of already imported modules), raises a SystemError:
import builtins
from importlib.machinery import PathFinder
from importlib.util import find_spec
import importlib
import sys
import _imp
dct={}
def copy_module(module):
new = type(sys)(module.__name__)
new.__dict__.update(module.__dict__)
return new
dct["__builtins__"] = b = copy_module(builtins)
spec = PathFinder.find_spec("_bootstrap",importlib.__path__)
source_bootstrap = type(sys)("_bootstrap");
spec.loader.exec_module(source_bootstrap);
source_bootstrap.__name__ = "importlib._bootstrap";
new_sys = copy_module(sys)
new_sys.path_hooks = []
new_sys.meta_path = []
new_sys.modules = {
"importlib._bootstrap":source_bootstrap,
"importlib._bootstrap_external":importlib._bootstrap_external,
}
b.__import__ = source_bootstrap.__import__
source_bootstrap._install(new_sys,_imp)
dct["__file__"]=__file__
exec("open(__file__)",dct)
The actual file passed to the open function doesn't matter, as long as it would work
----------
components: +IO, Interpreter Core, Library (Lib)
title: "SystemError: SystemError: <class '_io.TextIOWrapper'> returned NULL without setting an error -> "SystemError: SystemError: <class '_io.TextIOWrapper'> returned NULL without setting an error" from open function
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30626>
_______________________________________
More information about the Python-bugs-list
mailing list