[Python-Dev] [Python-3000-checkins] r45617 - in python/branches/p3yk/Lib/plat-mac/lib-scriptpackages: CodeWarrior/CodeWarrior_suite.py CodeWarrior/init.py Explorer/init.py Finder/Containers_and_folders.py Finder/Files.py Finder/Finder_Basics.py Finder (original) (raw)

Thomas Wouters thomas at python.org
Fri Apr 21 18:26:04 CEST 2006


On 4/21/06, guido.van.rossum <python-3000-checkins at python.org> wrote:

The hardest part was fixing two mutual recursive imports; somehow changing "import foo" into "from . import foo" where foo and bar import each other AND both are imported from init.py caused things to break. Bah.

Hm, this is possibly a flaw in the explicit relative import mechanism. Normal circular imports work because a module object is stuffed into sys.modules before any code for the module is executed, so the next 'import' of that module just finds the half-loaded module object. I guess 'from . import name' really looks at the package contents, though, and there, the module isn't stored until it's done loading. I'm not sure why it raises a 'cannot import name' exception instead of recursing into a spiral of death, but I guess that's a good thing. :)

Should this be fixed, or is it an esoteric enough case that I shouldn't bother?

-- Thomas Wouters <thomas at python.org>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-dev/attachments/20060421/3e3f1a1a/attachment.htm



More information about the Python-Dev mailing list