[svn r60141] refactor things such that all fallbacks to inspect.get/findsource happen in helpers in source.py

--HG--
branch : trunk
This commit is contained in:
pedronis
2008-11-25 19:34:47 +01:00
parent 5c8b04dacb
commit 1a150e9050
6 changed files with 71 additions and 23 deletions

View File

@@ -1,4 +1,5 @@
import py
from py.__.code import source
class Code(object):
""" wrapper around Python code objects """
@@ -75,14 +76,8 @@ class Code(object):
def fullsource(self):
""" return a py.code.Source object for the full source file of the code
"""
fn = self.raw.co_filename
try:
return fn.__source__
except AttributeError:
path = self.path
if not isinstance(path, py.path.local):
return None
return py.code.Source(self.path.read(mode="rU"))
full, _ = source.findsource(self.raw)
return full
fullsource = property(fullsource, None, None,
"full source containing this code object")