This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author barry
Recipients Alexandre.Badez, barry, eric.araujo, eric.snow, ncoghlan, pje
Date 2011-11-29.15:09:15
SpamBayes Score 3.8953302e-10
Marked as misclassified No
Message-id <20111129100908.7089f4eb@resist.wooz.org>
In-reply-to <1322571045.82.0.958223705822.issue11374@psf.upfronthosting.co.za>
Content
On Nov 29, 2011, at 12:50 PM, Éric Araujo wrote:

>Before you put more work into this, it would be nice to get confirmation from
>one import expert that the bug is valid: I know the import system only
>superficially, and I’m not sure that package/__init__.pyc / .pyo is supported
>by import (if not, then pkgutil should also not support it).

It's an interesting question.  Under Python 2, I'd say yes, it should support
source-less imports, just as Python does.  Under Python 3, with PEP 3147, I'm
not so sure:

$ cat > foo.py
print('hello world')
$ cat > bar.py
import foo
$ ls
bar.py	foo.py
$ python3 bar.py
hello world
$ ls
bar.py	foo.py	__pycache__/
$ ls __pycache__/
foo.cpython-32.pyc
$ rm -f foo.py
$ python3 bar.py
Traceback (most recent call last):
  File "bar.py", line 1, in <module>
    import foo
ImportError: No module named foo

Then:

$ mv __pycache__/foo.cpython-32.pyc foo.pyc
$ ls
bar.py	foo.pyc  __pycache__/
$ python3 bar.py
hello world

So Python 3 source-less imports are still supported, but only when legacy
.pyc/.pyo locations are explicitly used.

My inclination is then -0 on extend_path() supporting .pyc/.pyo but only
*outside* the context of PEP 3147.  I.e. do not use imp.cache_from_source().
History
Date User Action Args
2011-11-29 15:09:16barrysetrecipients: + barry, pje, ncoghlan, eric.araujo, Alexandre.Badez, eric.snow
2011-11-29 15:09:15barrylinkissue11374 messages
2011-11-29 15:09:15barrycreate