[pypy-svn] pypy default: Fix the hack used to retrieve the class of a function

amauryfa commits-noreply at bitbucket.org
Tue Jan 25 01:06:46 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: 
Changeset: r41280:c4fdc7631e3d
Date: 2011-01-25 01:03 +0100
http://bitbucket.org/pypy/pypy/changeset/c4fdc7631e3d/

Log:	Fix the hack used to retrieve the class of a function when all you
	have is the code object.

diff --git a/lib-python/modified-2.7.0/trace.py b/lib-python/modified-2.7.0/trace.py
--- a/lib-python/modified-2.7.0/trace.py
+++ b/lib-python/modified-2.7.0/trace.py
@@ -546,6 +546,10 @@
             if len(funcs) == 1:
                 dicts = [d for d in gc.get_referrers(funcs[0])
                              if isinstance(d, dict)]
+                if len(dicts) == 0:
+                    # PyPy may store functions directly on the class
+                    # (more exactly: the container is not a Python object)
+                    dicts = funcs
                 if len(dicts) == 1:
                     classes = [c for c in gc.get_referrers(dicts[0])
                                    if hasattr(c, "__bases__")]


More information about the Pypy-commit mailing list