[Python-Dev] Inconsistent behaviour in import/zipimport hooks
Guido van Rossum
guido at python.org
Wed Nov 9 04:14:51 CET 2005
You didn't show us what's in the zip file. Can you show a zipinfo output?
My intention with import was always that without -O, *.pyo files are
entirely ignored; and with -O, *.pyc files are entirely ignored.
It sounds like you're saying that you want to change this so that .pyc
and .pyo are always honored (with .pyc preferred if -O is not present
and .pyo preferred if -O is present). I'm not sure that I like that
better. If that's how zipimport works, I think it's broken!
--Guido
On 11/8/05, Osvaldo Santana Neto <osantana at gmail.com> wrote:
> Hi,
>
> I'm working on Python[1] port for Maemo Platform[2] and I've found a
> inconsistent behavior in zipimport and import hook with '.pyc' and
> '.pyo' files. The shell section below show this problem using a
> 'module_c.pyc', 'module_o.pyo' and 'modules.zip' (with module_c and
> module_o inside):
>
> $ ls
> module_c.pyc module_o.pyo modules.zip
>
> $ python
> >>> import module_c
> >>> import module_o
> ImportError: No module named module_o
>
> $ python -O
> >>> import module_c
> ImportError: No module named module_c
> >>> import module_o
>
> $ rm *.pyc *.pyo
> $ PYTHONPATH=modules.zip python
> >>> import module_c
> module_c
> >>> import module_o
> module_o
>
> $ PYTHONPATH=modules.zip python -O
> >>> import module_c
> module_c
> >>> import module_o
> module_o
>
> I've create a patch suggestion to remove this inconsistency[3] (*I* think
> zipimport behaviour is better).
>
> [1] http://pymaemo.sf.net/
> [2] http://www.maemo.org/
> [3] http://python.org/sf/1346572
>
> --
> Osvaldo Santana Neto (aCiDBaSe)
> icq, url = (11287184, "http://www.pythonbrasil.com.br")
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org
>
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev
mailing list