[Python-bugs-list] [ python-Bugs-661136 ] zipimport does not accept nested pure python imports
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 03 Jan 2003 03:22:48 -0800
Bugs item #661136, was opened at 2003-01-02 16:54
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=661136&group_id=5470
Category: Python Library
Group: Python 2.3
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Sandy Norton (sandynorton)
Assigned to: Just van Rossum (jvr)
Summary: zipimport does not accept nested pure python imports
Initial Comment:
I presume this is a big with zipimport. It occurs when
you have a nested pure python package structure. It
doesn't occcur if there are byte-compiled versions in
the zipped directory.
as pure python zipped directory
===============================
Assume mylib.zip is inserted on the sys.path with the
following
directory structure:
mylib.zip
mod.py
p1
__init__.py
mod.py
p2
__init__.py
mod.py
C:\TMP>ls
mylib.zip
C:\TMP>p
Python 2.3a1 (#38, Jan 1 2003, 16:44:16) [MSC v.1200
32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for
more information.
>>> import sys; sys.path.insert(0, 'c:\tmp\mylib.zip')
>>> import mod
mod
>>> from p1 import mod
Traceback (most recent call last):
File "<stdin>", line 1, in ?
SystemError:
C:\Engines\python\dist\src\Objects\stringobject.c:3295:
bad argumen
t to internal function
>>> from p1.p2 import mod
Traceback (most recent call last):
File "<stdin>", line 1, in ?
SystemError:
C:\Engines\python\dist\src\Objects\stringobject.c:3295:
bad argumen
t to internal function
>>>
as plain directory
===================
C:\TMP>p
Python 2.3a1 (#38, Jan 1 2003, 16:44:16) [MSC v.1200
32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for
more information.
>>> import sys
>>> sys.path.insert(0, 'c:\tmp\mylib')
>>> import mod
mod
>>> from p1 import mod
mod1
>>> from p1.p2 import mod
mod2
>>>
as byte-compiled zipped directory
=================================
mylib.zip
mod.py
mod.pyc
p1
__init__.py
__init__.pyc
mod.py
mod.pyc
p2
__init__.py
__init__.pyc
mod.py
mod.pyc
C:\TMP>p
Python 2.3a1 (#38, Jan 1 2003, 16:44:16) [MSC v.1200
32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for
more information.
>>> import sys; sys.path.insert(0, 'c:\tmp\mylib.zip')
>>> import mod
mod
>>> import p1.mod
mod1
>>> import p1.p2.mod
mod2
>>> p1.p2.mod
<module 'p1.p2.mod' from 'c:\tmp\mylib.zip\p1\p2\mod.pyc'>
>>>
----------------------------------------------------------------------
>Comment By: Just van Rossum (jvr)
Date: 2003-01-03 12:22
Message:
Logged In: YES
user_id=92689
Ouch, nasty. It's not quite like you describe: the problem
occurs for any *empty* source file (that doesn't have a
matching .pyc in the archive). So I take it your mod.py
wasn't empty but p1/__init__.py and p1/p2/__init__.py were.
Fixed in rev. 1.8 of Modules/zipimport.c
Thanks for reporting this!
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=661136&group_id=5470