[svn r37322] Turned out there was a function for this already, even... Thanks, fijal!
--HG-- branch : trunk
This commit is contained in:
parent
ed55fea143
commit
ba07a8769f
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
import py
|
import py
|
||||||
from py.__.apigen.tracer import model
|
from py.__.apigen.tracer import model
|
||||||
|
from py.__.code.source import getsource
|
||||||
|
|
||||||
import types
|
import types
|
||||||
import inspect
|
import inspect
|
||||||
|
@ -18,20 +19,7 @@ class CallFrame(object):
|
||||||
self.filename = frame.code.raw.co_filename
|
self.filename = frame.code.raw.co_filename
|
||||||
self.lineno = frame.lineno
|
self.lineno = frame.lineno
|
||||||
self.firstlineno = frame.code.firstlineno
|
self.firstlineno = frame.code.firstlineno
|
||||||
|
self.source = getsource(frame.code.raw)
|
||||||
fname = frame.code.raw.co_filename
|
|
||||||
if fname == '<string>':
|
|
||||||
self.source = ''
|
|
||||||
elif hasattr(fname, '__source__'):
|
|
||||||
# is a py.code.Source object
|
|
||||||
self.source = str(fname.__source__)
|
|
||||||
# XXX should we do this?
|
|
||||||
# self.filename = fname.split('<')[1].split('>')[0]
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
self.source = frame.code.source()
|
|
||||||
except IOError:
|
|
||||||
raise IOError(self.filename)
|
|
||||||
|
|
||||||
def _getval(self):
|
def _getval(self):
|
||||||
return (self.filename, self.lineno)
|
return (self.filename, self.lineno)
|
||||||
|
|
Loading…
Reference in New Issue