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
Remove inconsistent behavior between import and zipimport #42549
Comments
Look the inconsistent behavior: $ python2.4
>>> import modulo_c
modulo_c
>>> import modulo_o
ImportError: No module named modulo_o
$ python2.4 -O
>>> import modulo_c
ImportError: No module named modulo_c
>>> import modulo_o
modulo_o $ rm *.pyc *.pyo
$ ls
modulos.zip
$ PYTHONPATH=modulos.zip python2.4
>>> import modulo_c
modulo_c
>>> import modulo_o
modulo_o
$ PYTHONPATH=modulos.zip python2.4 -O
>>> import modulo_c
modulo_c
>>> import modulo_o
modulo_o |
Logged In: YES The discussion on python-dev (both last year's and this |
Still an issue with 3.2: zipimport considers both pyc and pyo with or without -O. The discussion starts here: http://mail.python.org/pipermail/python-dev/2006-November/thread.html#69822 (This was originally closed instead of asking for another fix because SourceForge separated bugs and patches.) |
I need to qualify something: I reproduced the bug with legacy/pre-PEP 3147/in-the-same-dir pyc and pyo files. One could argue that pycache directories in 3.2+ make this irrelevant and that it’s too late for 2.x. |
I like that argument. =) If this is not an issue in Python 3.3 then this should be closed as out of date since it will break code if it is changed. |
It entirely depends on how much you care about pyc-only/pyo-only zipfile distributions, and compatibility between zipimport and importlib (i.e. if you don’t plan on matching the zipimport bug in importlib, might as well fix zipimport in 2.7 and 3.2). |
I don't care about compatibility between zipimport and importlib. |
OK, I’m leaving this open until the next weekly report just in case someone interested comes here and weighs in, otherwise I’ll close as wontfix. |
Does "compileall" generate both .pyc and .pyo by default? Or do you have to run it twice? If the latter, does pysetup handle that for you? MvL is correct that zipimport should ignore .pyo files when __debug__ is set and vice-versa, but the precompilation tools should also take care of generating both versions by default. |
|
Status quo sounds fine then. +1 for closing it again. |
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: