-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
module_from_spec #126039
Comments
|
This isn't true :) import builtins
name = "builtins"
spec = importlib.util.find_spec(name)
sys.modules[name] = "ha"
print(sys.modules[name]) # ha
importlib.util.module_from_spec(spec)
print(sys.modules[name]) # ha Perhaps I will present this part of my research soon. Although it was bullied on the main forum. |
Yes, because you don't overwrite |
In general, black magic with |
According to my research, all copies can be overwritten.
There are no problems for me here. At the python level, I can change everything myself.
For example? |
Sure, but that doesn't mean we have to support it :)
Truly overwriting the #define Py_BUILD_CORE
#include "pycore_interp.h"
static PyObject *
overwrite_sys_modules(PyObject *self, PyObject *obj)
{
PyInterpreterState *interp = PyInterpreterState_Get();
Py_SETREF(interp->imports.modules, Py_NewRef(obj));
Py_RETURN_NONE;
} |
This is understandable. It was only in the context of the behavior inconsistency in the original example here. But for me it's not a problem at all. I just decided to write :)
Thanks for the example. |
Bug report
Bug description:
This may not be a bug, but it's a weirdness.
Why is there an automatic implicit re-registration of the builtins module in the latter case?
CPython versions tested on:
3.12, 3.13
Operating systems tested on:
No response
The text was updated successfully, but these errors were encountered: