[Python-Dev] How to block a module import (original) (raw)

Nick Coghlan ncoghlan at gmail.com
Tue Jul 13 14:48:02 CEST 2010


On Tue, Jul 13, 2010 at 10:37 AM, Alexander Belopolsky <alexander.belopolsky at gmail.com> 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 "", line 1, in ImportError: No module named time  Am I missing something?

I don't think so. I suspect I got away with this mistake because the imports I was trying to block in the test suite were all C acceleration imports of the form "from import *", and those will blow up anyway since zero doesn't have dict or all attributes.

Cheers, Nick.

-- Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-Dev mailing list