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
Interpreter doesn't start when dynamic loading is disabled #68957
Comments
When attempting to build Python without dynamic loading (HAVE_DYNAMIC_LOADING is not defined), the module "_imp" will not have the function "exec_dynamic." However, Lib/bootstrap.py seems to assume that "_imp.exec_dynamic" exists, causing the error: ---- ./python -E -S -m sysconfig --generate-posix-vars ;\
if test $? -ne 0 ; then \
echo "generate-posix-vars failed" ; \
rm -f ./pybuilddir.txt ; \
exit 1 ; \
fi
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 1134, in _install
File "<frozen importlib._bootstrap>", line 1114, in _setup
File "<frozen importlib._bootstrap>", line 1082, in _builtin_from_name
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap>", line 748, in exec_module
AttributeError: module '_imp' has no attribute 'exec_dynamic'
Fatal Python error: Py_Initialize: importlib install failed Current thread 0x00000000 (most recent call first): when trying to build. This error means that Python 3.5 will not be able to build in a purely static (no dynamic loading whatsoever) form. This error was encountered in Python 3.5b4. |
This is an interesting find - thanks. Adding Larry as 3.5 release manager to the cc here, as I think the right fix actually involves an API adjustment inside _imp. One of the consequences of PEP-489 (multi-phase initialisation) was that builtin imports and extension module imports now share a lot more code, and that includes the fact that while we have both _imp.create_builtin and _imp.create_dynamic, they currently share a module level exec implementation in _imp.exec_dynamic. However, the definition and implementation of _imp.exec_dynamic is still behind the same preprocessor guard as _imp.create_dynamic, hence the error reported here. As far as a fix goes, rather than defining _imp.exec_dynamic unconditionally, my inclination is to say that merging the Python level APIs in addition to the underyling C level implementation represents a design mistake when we implemented the PEP, and there should be a separate _imp.exec_builtin function. The fact that _imp.exec_dynamic just called _imp.exec_builtin internally would then be a pure CPython implementation detail, rather than something importlib specifically depended on. |
Apologies for the delay; I was on vacation. This was indeed a mistake in PEP-489 implementation. I agree with Nick on the solution. |
Looks fine to me. Nick had suggested calling exec_builtin from exec_dynamic (to the same effect as your patch), but I don't consider that much of an issue. :) |
Right. I think a common helper is cleaner than calling a clinic-generated wrapper. |
Uh, Nick? You didn't add me to this bug. |
Patch looks good to me too. I think this needs to be put forward as a PR to bitbucket right? It looks Release Critical to me. |
It's ultimately Larry's call, but I think it should go into 3.5.0. |
Yes, I'll accept this into 3.5.0, please send a pull request. |
I wanted to get this in to Python 3.5.0rc2, so I checked it in myself. Petr, I gave you credit in the checkin comment and Misc/NEWS. Hope that's okay! |
Thanks Larry! Sorry I didn't get to this as soon as I got back from the US. Will you add it to 3.5.1 and 3.6.0, or would you prefer I take care of that? |
I pulled the 3.5 branch a few minutes ago, and the patch isn't present. Has it not been pushed to hg.python.org? |
That's correct, it's just in 3.5.0 at the moment. |
I have merged it forward into 3.5.1 and 3.6. |
New changeset 931593401e3e by Larry Hastings in branch '3.5': |
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: