[issue17636] Modify IMPORT_FROM to fallback on sys.modules

Phillip J. Eby report at bugs.python.org
Fri Apr 5 19:31:19 CEST 2013


Phillip J. Eby added the comment:

Actually, after a little reflection, I can see that there are more
complex conditions to analyze, if 'b' doesn't import 'b.util', but
some other module imports b and sets b.util.  But that's just freaking
insane and whoever does that probably deserves whatever they get,
especially since a later 'import b.util' would blow away the modified
attribute.

So, this note is just to satisfy myself that the change doesn't
introduce any *new* weirdness unless you are in a case where the
parent imports and replaces the child, and the child is involved in an
import cycle.  If the parent doesn't import the child but just assigns
an attribute, it's already broken the minute somebody else imports the
child, and the same thing applies if something else sets the attribute
without importing the child first, and if it imports the child first,
then the previous analysis (mostly) applies, but either way that code
is broken and will have plenty of other ordering dependencies to debug
on its own.  ;-)

(No wonder Nick said nobody wanted to touch this...  the analysis
alone is a killer.  ;-)   Luckily, it seems we're good to go unless
somebody can find a case I missed.)

----------

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


More information about the Python-bugs-list mailing list