[pypy-svn] r32238 - pypy/dist/pypy/tool

arigo at codespeak.net arigo at codespeak.net
Tue Sep 12 20:56:36 CEST 2006


Author: arigo
Date: Tue Sep 12 20:56:35 2006
New Revision: 32238

Modified:
   pypy/dist/pypy/tool/sourcetools.py
Log:
(arigo, pedronis)

fix repetition of class names in FunctionGraph reprs. Very important fix! 



Modified: pypy/dist/pypy/tool/sourcetools.py
==============================================================================
--- pypy/dist/pypy/tool/sourcetools.py	(original)
+++ pypy/dist/pypy/tool/sourcetools.py	Tue Sep 12 20:56:35 2006
@@ -254,16 +254,13 @@
 
 def nice_repr_for_func(fn, name=None):
     mod = getattr(fn, '__module__', None)
-    if mod is None:
-        mod = '?'
     if name is None:
         name = getattr(fn, '__name__', None)
-    if name is not None:
+        cls = getattr(fn, 'class_', None)
+        if name is not None and cls is not None:
+            name = "%s.%s" % (cls.__name__, name)
+    try:
         firstlineno = fn.func_code.co_firstlineno
-    else:
-        name = 'UNKNOWN'
+    except AttributeError:
         firstlineno = -1
-    cls = getattr(fn, 'class_', None)
-    if cls is not None:
-        name = "%s.%s" % (cls.__name__, name)
-    return "(%s:%d)%s" % (mod, firstlineno, name)
+    return "(%s:%d)%s" % (mod or '?', firstlineno, name or 'UNKNOWN')



More information about the Pypy-commit mailing list