[Numpy-discussion] Crash on (un-orthodox) __import__

Robert Kern robert.kern@gmail....
Thu Oct 6 23:33:01 CDT 2011

On Thu, Oct 6, 2011 at 17:25, Paul Ivanov <pivanov314@gmail.com> wrote:
> Hi Andrea,
> On Tue, Oct 4, 2011 at 3:04 AM, Andrea Gavana <andrea.gavana@gmail.com> wrote:
>> Hi All,
>>     I was fiddling here and there with some code doing dynamic import of
>> stuff, and I noticed that this code:
>> import os
>> import sys
>> init_name = r"C:\Python27\Lib\site-packages\numpy\__init__.py"
>> directory, module_name = os.path.split(init_name)
>> main = os.path.splitext(module_name)[0]
>> sys.path.insert(0, os.path.normpath(directory))
>> # Crash here...
>> mainmod = __import__(main)
> in this case, your main is '__init__' and your directory is
> 'C:\Python27\Lib\site-packages\numpy' which is probably not what you
> intended. You should make directory 'C:\Python27\Lib\site-packages'
> and main into 'numpy'

Still, it shouldn't segfault, and it's worth figuring out why it does.
gdb has been mostly unenlightening for me since gdb won't let me
navigate the traceback.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco

More information about the NumPy-Discussion mailing list