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

hpk at codespeak.net hpk at codespeak.net
Sun Jan 2 12:31:02 CET 2005


Author: hpk
Date: Sun Jan  2 12:31:01 2005
New Revision: 8031

Modified:
   py/dist/py/code/excinfo.py
   py/dist/py/code/frame.py
Log:
- return None if source code cannot be found or read 

- a more telling __repr__ for TracebackEntries 



Modified: py/dist/py/code/excinfo.py
==============================================================================
--- py/dist/py/code/excinfo.py	(original)
+++ py/dist/py/code/excinfo.py	Sun Jan  2 12:31:01 2005
@@ -95,3 +95,6 @@
     def path(self): 
         return self.frame.path 
     path = property(path, None, None, "path to the full source code")
+
+    def __repr__(self): 
+        return "<TracebackEntry %s:%d>" %(self.frame.code.path, self.lineno + 1)

Modified: py/dist/py/code/frame.py
==============================================================================
--- py/dist/py/code/frame.py	(original)
+++ py/dist/py/code/frame.py	Sun Jan  2 12:31:01 2005
@@ -16,7 +16,10 @@
         try: 
             return fn.__source__ 
         except AttributeError: 
-            return py.code.Source(self.path.read(mode="rU"))
+            try: 
+                return py.code.Source(self.path.read(mode="rU"))
+            except py.path.NotFound: 
+                return None 
     fullsource = property(fullsource, None, None, 
                           "full source containing this code object") 
 



More information about the pytest-commit mailing list