Message190689
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). |
|
Date |
User |
Action |
Args |
2013-06-05 20:11:43 | brett.cannon | set | recipients:
+ brett.cannon, antoine.pietri |
2013-06-05 20:11:43 | brett.cannon | set | messageid: <1370463103.08.0.174229858596.issue18145@psf.upfronthosting.co.za> |
2013-06-05 20:11:43 | brett.cannon | link | issue18145 messages |
2013-06-05 20:11:42 | brett.cannon | create | |
|