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 brett.cannon
Recipients antoine.pietri, brett.cannon
Date 2013-06-05.20:11:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1370463103.08.0.174229858596.issue18145@psf.upfronthosting.co.za>
In-reply-to
Content
It's because you have a nested circular import. When you import package2.subpackage from within package2.subpackage you're in package2 importing package2 and also in package2.subpackage importing package2.subpackage.

You can solve your problem by doing either ``from package2.subpackage import foo`` for ``from . import foo`` as that lets package2.subpackage be imported entirely on its own before attempting package2.subpackage.foo and thus letting the circular loop unroll and have the right attributes set since the attributes of a module for a package are set after the import completes.

Might be annoying, but tweaking this would probably break code if changed as it's very old semantics to set the attribute of a module on a package after other imports complete. This is also not a problem as long as you don't do this in an __init__ (e.g. importing package2.subpackage.bar from package2.subpackage.foo is not a problem).
History
Date User Action Args
2013-06-05 20:11:43brett.cannonsetrecipients: + brett.cannon, antoine.pietri
2013-06-05 20:11:43brett.cannonsetmessageid: <1370463103.08.0.174229858596.issue18145@psf.upfronthosting.co.za>
2013-06-05 20:11:43brett.cannonlinkissue18145 messages
2013-06-05 20:11:42brett.cannoncreate