[Python-ideas] Detecting circular imports ?

Nick Coghlan ncoghlan at gmail.com
Fri Nov 19 14:31:09 CET 2010

On Fri, Nov 19, 2010 at 11:15 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> Feel free to take a shot at it - the relevant bug report [1] is only a
> little over 6 years old! :)
> [1] http://bugs.python.org/issue992389

Less facetiously, there are 3 different things suggested in that bug
report that people could try:

1. Implement the set-and-rollback feature for submodule attributes in
parent packages during import
2. Implement the "try looking for the fully qualified name in
sys.modules" idea(/hack)
3. Track in-progress imports and throw specific errors if the import
code trips over one

The last option does have the advantage of requiring less coordination
with the developers of other implementations (given the subtleties of
this issue, I'd want feedback from at least PyPy, IronPython and
Jython as to what they can handle before we started messing with the
semantics of what the language allows as far as circular imports go)

The issue suffers from the fact that at least some of the people with
the knowledge to do something about it are not inclined to do so due
to strong stylistic objections (*ahem*).


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-ideas mailing list