[IPython-dev] __file__ bug

sebastian rooks sebastian.rooks at free.fr
Tue Jun 27 09:58:01 EDT 2006

Hi guys,

With the file test.py containing:
  print __file__

In ipython 0.7.2:
  In [1]: run test.py

The __file__ attribute is set in Magic.py (rev 1380) by:
  1473 	        # Since '%run foo' emulates 'python foo.py' at the cmd line, we must
  1474 	        # set the __file__ global in the script's namespace
  1475 	        prog_ns['__file__'] = filename

but in the same file, the line:
  1484 	        sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)

modify the __file__ value through a change introduce by changeset 1322 line 39
in FakeModule.py:
  38	        # modules should have a __file__ attribute 
  39	        adict['__file__'] = __file__ 

As a quick fix I commented line 39 in FakeModule.py but obviously it is not the
correct bugfix.

Thank you for ipython, I do like it !


More information about the IPython-dev mailing list