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.

classification
Title: zipimport on meta_path fails with mutual importers
Type: Stage:
Components: Documentation, Library (Lib) Versions: Python 2.6, Python 2.5
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: brett.cannon Nosy List: brett.cannon, jvr, timmcl
Priority: normal Keywords:

Created on 2003-08-12 02:25 by timmcl, last changed 2022-04-10 16:10 by admin. This issue is now closed.

Messages (3)
msg17723 - (view) Author: Tim McLennan (timmcl) Date: 2003-08-12 02:25
If I create a simple package consisting of a
package/__init__.py containing:
  print "Package: "+__name__
  import module

and a package/module.py containing:
  print "Module: "+__name__
  import package

and zip the directory resulting directory up, then it
imports fine if I add the zip to sys.path

However if Instead create a zipimporter object and add
it to the meta_path then I get a whole heap of
recursive imports resulting in  output of the following
form:
Package: package
Module: package.module
Package: package.package
Module: package.package.module
Package: package.package.package
Module: package.package.package.module
Package: package.package.package.package
Module: package.package.package.package.module
Package: package.package.package.package.package
....
before finally running into an exception:
ValueError: Module name too long

For reference my version string is '2.3 (#46, Jul 29
2003, 18:54:32) [MSC v.1200 32 bit (Intel)]'
msg17724 - (view) Author: Just van Rossum (jvr) * (Python triager) Date: 2003-08-13 14:30
Logged In: YES 
user_id=92689

Hm, good catch! I don't see an obvious fix for this, and I worry 
that this is the result of a design flaw in the interaction between 
meta importers and path importers. For now, I think I should 
document that the zipimporter object is not suited for use on 
sys.meta_path. I need to do more thinking here.
msg85158 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2009-04-02 04:13
The zipimporter is not designed to work on sys.meta_path, so closing as
"won't fix".
History
Date User Action Args
2022-04-10 16:10:36adminsetgithub: 39051
2009-04-02 04:13:34brett.cannonsetstatus: open -> closed
resolution: wont fix
messages: + msg85158
2009-02-11 02:50:47ajaksu2setassignee: jvr -> brett.cannon
nosy: + brett.cannon
2008-01-05 18:05:19christian.heimessetcomponents: + Documentation, Library (Lib), - None
versions: + Python 2.6, Python 2.5
2003-08-12 02:25:41timmclcreate