Guido van Rossum wrote: >> * Circular imports should fail more nicely. Everyone suffers this at >> some time; maybe it can't be fixed, but at least it should be clear >> what's happening. > > It probably can't be fixed (or do you see a fix?). Do you mean it > should be easier to debug, or do you mean it should be explained > better how things work?
Currently, if you hit a recursive import, it either works (if the name that's been looking for in the module which causes the recursion was already bound) or doesn't work and abort with ImportError/AttributeError/NameError (if the name was not bound yet). I think this behaviour is inconsitent, and the error message (along the lines of "foo is not in module bar") is not meaningful because "foo" *is* defined in module "bar", just not *yet*. I guess there are a couple of things we can do: 1) Generate a better error message. If an import statement does not find name A in module M, and module M is being recursively imported, the error message could hint at the problem. 2) Totally disallow recursive imports (!). If import is called for module A, while module was already *being* imported, an ImportError is generated with message "recursive import of module A". The stack trace should make pretty clear the exact source of the problem. Of course, there should be better ways of doing this... -- Giovanni Bajo _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
