Brett Cannon added the comment:
Import now has proper messaging of the failure in the package and not an error
about being unable to import the submodule.
--
resolution: -> fixed
stage: -> resolved
status: open -> closed
___
Python tracker
Nick Coghlan added the comment:
import-sig is probably a better place to start
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17716
___
___
Pascal Chambon added the comment:
Well, since it's a tough decision to make (erasing all children modules when
rolling back parent, or instead reconnecting with children on 2nd import of
parent), I guess it should be discussed on python-dev first, shouldn't it ?
--
Pascal Chambon added the comment:
(sorry for the long post, but it's a complex issue I guess)
I forgot to precise that I have this behaviour with the latest python2.7, as
well as python3.3 (I guess other versions behave the same).
I agree that having side effects in script imports looks
Brett Cannon added the comment:
Have to think about the whole rollback situation in terms of a failure to
import a parent. Whenever you want to change the semantics of import you will
break someone's code, it's just a question of how wide the breakage would be
and how much of an improvement
Nick Coghlan added the comment:
The interpreter level problem covered by the current issue is that the
difference between import mypkg.module_a and from mypkg import module_a is
masking the fact that it is the original import mypkg that failed, and may
still fail on the second and subsequent
Nick Coghlan added the comment:
More generally, I think we may have to revisit the question of what we remove
from sys.modules on failure if, as a side effect of the import, a child module
was imported successfully.
In this situation, the possibilities are:
1. Remove the parent module, and
Pascal Chambon added the comment:
Thanks for the feedback, I'm gonna read those docs and related issues asap, and
check that planned evolutions will actually fix this.
just as a side note in the meantime: I dont think that the problem here is the
purge of sys.modules, the failure is actually
Brett Cannon added the comment:
TL;DR: don't do anything involving side-effects as part of an import that can
fail like connecting to a database. Another bug that proposes tweaking the
IMPORT_FROM bytecode semantics will more than likely solve your problem
regardless.
First question: what