[issue16031] relative import headaches

Nick Coghlan report at bugs.python.org
Tue Sep 25 07:47:34 CEST 2012


Nick Coghlan added the comment:

There is no magic bullet, but there are a whole mess of backwards compatibility constraints.

Closing this as a duplicate, because there's no clear resolvable RFE here beyond the known issues with circular imports and the differences between lazy and eager imports (already well documented in #992389, although potentially easier to resolve in 3.4 now that we have migrated to importlib).

Much of the rest of the complaint looks like a bug in pydev, as it appears to be running from a string *without creating an appropriate entry in sys.modules* first. Thus it *is* running through test_a twice due to the self import.

Many of these apparent import problems stem from poor reimplementations of import mechanics in tools like pydev and nose violating import system invariants. With importlib being used as the reference import implementation and the language reference finally including formally documented import semantics in 3.3+, this problem should hopefully reduce over time, as these ad hoc reimplementations are replaced by appropriate usage of importlib and runpy.

(Of course, the import system initialisation process is not without problems of its own, as PEP 395 describes)

----------
nosy: +ncoghlan
resolution:  -> duplicate
status: open -> closed
superseder:  -> attribute error due to circular import
versions: +Python 3.4 -Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16031>
_______________________________________


More information about the Python-bugs-list mailing list