##// END OF EJS Templates
Improve the monkeypatch to inspect.findsource() to find source lines inside of zipped packages.
rkern -
Show More
@@ -60,7 +60,7 b' You can implement other color schemes easily, the syntax is fairly'
60 self-explanatory. Please send back new schemes you develop to the author for
60 self-explanatory. Please send back new schemes you develop to the author for
61 possible inclusion in future releases.
61 possible inclusion in future releases.
62
62
63 $Id: ultraTB.py 2480 2007-07-06 19:33:43Z fperez $"""
63 $Id: ultraTB.py 2883 2007-12-02 02:54:17Z rkern $"""
64
64
65 #*****************************************************************************
65 #*****************************************************************************
66 # Copyright (C) 2001 Nathaniel Gray <n8gray@caltech.edu>
66 # Copyright (C) 2001 Nathaniel Gray <n8gray@caltech.edu>
@@ -135,11 +135,18 b' def findsource(object):'
135 FIXED version with which we monkeypatch the stdlib to work around a bug."""
135 FIXED version with which we monkeypatch the stdlib to work around a bug."""
136
136
137 file = getsourcefile(object) or getfile(object)
137 file = getsourcefile(object) or getfile(object)
138 # If the object is a frame, then trying to get the globals dict from its
139 # module won't work. Instead, the frame object itself has the globals
140 # dictionary.
141 globals_dict = None
142 if inspect.isframe(object):
143 # XXX: can this ever be false?
144 globals_dict = object.f_globals
145 else:
138 module = getmodule(object, file)
146 module = getmodule(object, file)
139 if module:
147 if module:
140 lines = linecache.getlines(file, module.__dict__)
148 globals_dict = module.__dict__
141 else:
149 lines = linecache.getlines(file, globals_dict)
142 lines = linecache.getlines(file)
143 if not lines:
150 if not lines:
144 raise IOError('could not get source code')
151 raise IOError('could not get source code')
145
152
@@ -1,3 +1,9 b''
1 2007-12-01 Robert Kern <robert.kern@gmail.com>
2
3 * IPython/ultraTB.py (findsource): Improve the monkeypatch to
4 inspect.findsource(). It can now find source lines inside zipped
5 packages.
6
1 2007-11-29 *** Released version 0.8.2
7 2007-11-29 *** Released version 0.8.2
2
8
3 2007-11-25 Fernando Perez <Fernando.Perez@colorado.edu>
9 2007-11-25 Fernando Perez <Fernando.Perez@colorado.edu>
General Comments 0
You need to be logged in to leave comments. Login now