##// END OF EJS Templates
- fix missing __file__ for scripts run via %run....
fperez -
r122:0c35e2ff
parent child
Show More
@@ -15,7 +15,7 details on the PSF (Python Software Foundation) standard license, see:
15
15
16 http://www.python.org/2.2.3/license.html
16 http://www.python.org/2.2.3/license.html
17
17
18 $Id: Debugger.py 994 2006-01-08 08:29:44Z fperez $"""
18 $Id: Debugger.py 1029 2006-01-18 07:33:38Z fperez $"""
19
19
20 #*****************************************************************************
20 #*****************************************************************************
21 #
21 #
@@ -66,12 +66,22 def _file_lines(fname):
66
66
67 class Pdb(pdb.Pdb):
67 class Pdb(pdb.Pdb):
68 """Modified Pdb class, does not load readline."""
68 """Modified Pdb class, does not load readline."""
69
70 # Ugly hack: we can't call the parent constructor, because it binds
71 # readline and breaks tab-completion. This means we have to COPY the
72 # constructor here, and that requires tracking various python versions.
73
69 def __init__(self,color_scheme='NoColor'):
74 def __init__(self,color_scheme='NoColor'):
70 bdb.Bdb.__init__(self)
75 bdb.Bdb.__init__(self)
71 cmd.Cmd.__init__(self,completekey=None) # don't load readline
76 cmd.Cmd.__init__(self,completekey=None) # don't load readline
72 self.prompt = 'ipdb> ' # The default prompt is '(Pdb)'
77 self.prompt = 'ipdb> ' # The default prompt is '(Pdb)'
73 self.aliases = {}
78 self.aliases = {}
74
79
80 # These two lines are part of the py2.4 constructor, let's put them
81 # unconditionally here as they won't cause any problems in 2.3.
82 self.mainpyfile = ''
83 self._wait_for_mainpyfile = 0
84
75 # Read $HOME/.pdbrc and ./.pdbrc
85 # Read $HOME/.pdbrc and ./.pdbrc
76 try:
86 try:
77 self.rcLines = _file_lines(os.path.join(os.environ['HOME'],
87 self.rcLines = _file_lines(os.path.join(os.environ['HOME'],
@@ -1,7 +1,7
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Magic functions for InteractiveShell.
2 """Magic functions for InteractiveShell.
3
3
4 $Id: Magic.py 1023 2006-01-16 19:11:21Z vivainio $"""
4 $Id: Magic.py 1029 2006-01-18 07:33:38Z fperez $"""
5
5
6 #*****************************************************************************
6 #*****************************************************************************
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
@@ -1396,6 +1396,10 Currently the magic system has the following functions:\n"""
1396 name = '__main__'
1396 name = '__main__'
1397 prog_ns = {'__name__':name}
1397 prog_ns = {'__name__':name}
1398
1398
1399 # Since '%run foo' emulates 'python foo.py' at the cmd line, we must
1400 # set the __file__ global in the script's namespace
1401 prog_ns['__file__'] = filename
1402
1399 # pickle fix. See iplib for an explanation. But we need to make sure
1403 # pickle fix. See iplib for an explanation. But we need to make sure
1400 # that, if we overwrite __main__, we replace it at the end
1404 # that, if we overwrite __main__, we replace it at the end
1401 if prog_ns['__name__'] == '__main__':
1405 if prog_ns['__name__'] == '__main__':
@@ -1,3 +1,15
1 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/Magic.py (magic_run): fix __file__ global missing from
4 script's namespace when executed via %run. After a report by
5 Vivian.
6
7 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
8 when using python 2.4. The parent constructor changed in 2.4, and
9 we need to track it directly (we can't call it, as it messes up
10 readline and tab-completion inside our pdb would stop working).
11 After a bug report by R. Bernstein <rocky-AT-panix.com>.
12
1 2006-01-16 Ville Vainio <vivainio@gmail.com>
13 2006-01-16 Ville Vainio <vivainio@gmail.com>
2
14
3 * Ipython/magic.py:Reverted back to old %edit functionality
15 * Ipython/magic.py:Reverted back to old %edit functionality
General Comments 0
You need to be logged in to leave comments. Login now