> Nick's right; 0 fails on an import * to pull anything in of interest. And as
> I said on python-checkins -- you can ignore that email, Alexander -- there
> is a historical reason because in Python 2 if you tried an implicit relative
> import a value of None met to do an absolute import. This does
On Tue, Jul 13, 2010 at 4:34 PM, Brett Cannon wrote:
..
> Nick's right; 0 fails on an import * to pull anything in of interest.
but if the imported module has
try:
import blocked_module
except ImportError:
do_something_important()
then import_fresh_module() will create a broken module wit
On Tue, Jul 13, 2010 at 05:48, Nick Coghlan wrote:
> On Tue, Jul 13, 2010 at 10:37 AM, Alexander Belopolsky
> wrote:
> > In my experiments, 0 is not equivalent to None:
> >
> import sys, time
> sys.modules['time'] = 0
> __import__('time')
> > 0
> sys.modules['time'] = None
>
On Tue, Jul 13, 2010 at 10:37 AM, Alexander Belopolsky
wrote:
> In my experiments, 0 is not equivalent to None:
>
import sys, time
sys.modules['time'] = 0
__import__('time')
> 0
sys.modules['time'] = None
__import__('time')
> Traceback (most recent call last):
> File "",
I thought that in order to block a module from being imported, one
would need to assign None to the corresponding entry in sys.modules.
However, it looks like the code in test.support uses 0 instead of
None:
def _save_and_block_module(name, orig_modules):
"""Helper function to save and block a