From ba07a8769f3be6d475a6931a7cd9e6ec0f9ba025 Mon Sep 17 00:00:00 2001 From: guido Date: Thu, 25 Jan 2007 12:59:02 +0100 Subject: [PATCH] [svn r37322] Turned out there was a function for this already, even... Thanks, fijal! --HG-- branch : trunk --- py/apigen/tracer/description.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/py/apigen/tracer/description.py b/py/apigen/tracer/description.py index 1e4c86c51..076a4b188 100644 --- a/py/apigen/tracer/description.py +++ b/py/apigen/tracer/description.py @@ -1,6 +1,7 @@ import py from py.__.apigen.tracer import model +from py.__.code.source import getsource import types import inspect @@ -18,20 +19,7 @@ class CallFrame(object): self.filename = frame.code.raw.co_filename self.lineno = frame.lineno self.firstlineno = frame.code.firstlineno - - fname = frame.code.raw.co_filename - if fname == '': - 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) + self.source = getsource(frame.code.raw) def _getval(self): return (self.filename, self.lineno)