[pypy-svn] r58897 - in pypy/branch/builtin-profiling/pypy/interpreter: . test

arigo at codespeak.net arigo at codespeak.net
Fri Oct 10 13:02:02 CEST 2008


Author: arigo
Date: Fri Oct 10 13:02:01 2008
New Revision: 58897

Modified:
   pypy/branch/builtin-profiling/pypy/interpreter/function.py
   pypy/branch/builtin-profiling/pypy/interpreter/test/test_executioncontext.py
Log:
(antocuni, arigo)
Test and fix for an assert that can trigger.


Modified: pypy/branch/builtin-profiling/pypy/interpreter/function.py
==============================================================================
--- pypy/branch/builtin-profiling/pypy/interpreter/function.py	(original)
+++ pypy/branch/builtin-profiling/pypy/interpreter/function.py	Fri Oct 10 13:02:01 2008
@@ -506,10 +506,8 @@
 def is_builtin_code(w_func):
     from pypy.interpreter.gateway import BuiltinCode
     if isinstance(w_func, Method):
-        w_f = w_func.w_function
-        assert isinstance(w_f, Function)
-        code = w_f.getcode()
-    elif isinstance(w_func, Function):
+        w_func = w_func.w_function
+    if isinstance(w_func, Function):
         code = w_func.getcode()
     else:
         code = None

Modified: pypy/branch/builtin-profiling/pypy/interpreter/test/test_executioncontext.py
==============================================================================
--- pypy/branch/builtin-profiling/pypy/interpreter/test/test_executioncontext.py	(original)
+++ pypy/branch/builtin-profiling/pypy/interpreter/test/test_executioncontext.py	Fri Oct 10 13:02:01 2008
@@ -140,7 +140,37 @@
             max(1, 2)
 
         bar()
+        sys.setprofile(None)
         return l
         """)
         events = space.unwrap(w_events)
-        assert events == ['return', 'c_call', 'c_return', 'return', 'return']
+        assert events == ['return', 'c_call', 'c_return', 'return', 'c_call']
+
+    def test_c_call_setprofile_strange_method(self):
+        space = self.space
+        w_events = space.appexec([], """():
+        import sys
+        class A(object):
+            def __init__(self, value):
+                self.value = value
+            def meth(self):
+                pass
+        MethodType = type(A.meth)
+        strangemeth = MethodType(A, 42, int)
+        l = []
+        def profile(frame, event, arg):
+            l.append(event)
+
+        def foo():
+            sys.setprofile(profile)
+
+        def bar():
+            foo()
+            strangemeth()
+
+        bar()
+        sys.setprofile(None)
+        return l
+        """)
+        events = space.unwrap(w_events)
+        assert events == ['return', 'call', 'return', 'return', 'c_call']



More information about the Pypy-commit mailing list