[Python-ideas] Detecting circular imports ?

M.-A. Lemburg mal at egenix.com
Fri Nov 19 16:37:40 CET 2010

Nick Coghlan wrote:
> 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*).

How would the implementation differentiate between a real attribute
error (missing symbol while setting up a module) and one caused by
a circular import (symbol available, but not yet defined) ?

Marc-Andre Lemburg

Professional Python Services directly from the Source  (#1, Nov 19 2010)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/

::: Try our new mxODBC.Connect Python Database Interface for free ! ::::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611

More information about the Python-ideas mailing list