[py-svn] r13033 - py/dist/py/code

dstanek at codespeak.net dstanek at codespeak.net
Fri Jun 3 13:01:11 CEST 2005


Author: dstanek
Date: Fri Jun  3 13:01:11 2005
New Revision: 13033

Modified:
   py/dist/py/code/frame.py
Log:
Removed duplication in frame.py by removing the Code class and instead 
using py.code.Code.


Modified: py/dist/py/code/frame.py
==============================================================================
--- py/dist/py/code/frame.py	(original)
+++ py/dist/py/code/frame.py	Fri Jun  3 13:01:11 2005
@@ -1,42 +1,12 @@
 import py
 
-class Code(object):
-    def __init__(self, f_code):
-        f_code = getattr(f_code, 'im_func', f_code) 
-        f_code = getattr(f_code, 'func_code', f_code) 
-        self._raw = f_code
-        try: 
-            self.firstlineno = f_code.co_firstlineno - 1
-        except AttributeError: 
-            raise TypeError("not a code object: %r" %(f_code,))
-        self.name = f_code.co_name
-
-    def path(self):
-        try:
-            return self._raw.co_filename.__path__
-        except AttributeError:
-            try: 
-                return py.path.local(self._raw.co_filename)
-            except ValueError: 
-                return None 
-    path = property(path, None, None, "path to source of this code object")
-
-    def fullsource(self):
-        fn = self._raw.co_filename
-        try:
-            return fn.__source__
-        except AttributeError:
-            return py.code.Source(self.path.read(mode="rU"))
-    fullsource = property(fullsource, None, None,
-                          "full source representing this code object")
-
 
 class Frame(object):
     """Wrapper around a Python frame holding f_locals and f_globals
     in which expressions can be evaluated."""
 
     def __init__(self, frame):
-        self.code = Code(frame.f_code)
+        self.code = py.code.Code(frame.f_code)
         self.lineno = frame.f_lineno - 1
         self.f_globals = frame.f_globals
         self.f_locals = frame.f_locals



More information about the pytest-commit mailing list