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: <class '_io.TextIOWrapper'> returned NULL without setting an error" from open function #74811
Comments
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: 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 |
I couldn't reproduce this on 3.7, but I can confirm that 3.6 gives a SystemError with the above code: $ ./python _issue30626.py
Traceback (most recent call last):
File "_issue30626.py", line 30, in <module>
exec("open(__file__)",dct)
File "<string>", line 1, in <module>
SystemError: <class '_io.TextIOWrapper'> returned NULL without setting an error It's plausible this was fixed as part of the interpreter startup refactoring, so I doubt we're going to able to easily isolate the specific change that fixed it :( |
That said: given that we know it *is* fixed somewhere in 3.7, it would likely be useful to check the assumption that the startup refactoring fixed it by going to the last commit before that landed and seeing if the error still occurs. |
In rare circumstances PyImport_Import() could return NULL without raising an error. It *isn't* fixed in 3.7. |
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: