__file__ not defined

Bug #400818 reported by Fazlul Shahriar
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
IPython
Fix Committed
Undecided
Unassigned

Bug Description

__file__ is not defined when the script is given as a command line agrument. It works fine when given to plain cpython. This is ipython 0.9.1 and cpython 2.6.2.

$ cat hello.py

print __file__
$ python hello.py
hello.py
$ ipython hello.py
/usr/lib/python2.6/site-packages/IPython/Magic.py:38: DeprecationWarning: the sets module is deprecated
  from sets import Set
---------------------------------------------------------------------------
NameError Traceback (most recent call last)

/tmp/hello.py in <module>()
      1
----> 2
      3 print __file__
      4
      5

NameError: name '__file__' is not defined
WARNING: Failure executing file: <hello.py>

In [1]:

Revision history for this message
Fernando Perez (fdo.perez) wrote :

Thanks for the report, fix committed to trunk in r1254.

Changed in ipython:
status: New → Fix Committed
Revision history for this message
Erik Allik (eallik) wrote :

Still experiencing this issue as if 0.12.1.

Revision history for this message
Erik Allik (eallik) wrote :

P.S. running an .ipy script, not a regular .py file—could be relevant.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.