[pypy-commit] pypy py3k: substitute gc.getreferents for getrefcount (thanks fijal)

pjenvey noreply at buildbot.pypy.org
Mon Feb 25 20:35:18 CET 2013


Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r61770:c1f8ea45dc6a
Date: 2013-02-25 11:33 -0800
http://bitbucket.org/pypy/pypy/changeset/c1f8ea45dc6a/

Log:	substitute gc.getreferents for getrefcount (thanks fijal)

diff --git a/lib-python/3.2/test/test_memoryview.py b/lib-python/3.2/test/test_memoryview.py
--- a/lib-python/3.2/test/test_memoryview.py
+++ b/lib-python/3.2/test/test_memoryview.py
@@ -11,7 +11,11 @@
 import array
 import io
 
-getrefcount = sys.getrefcount if hasattr(sys, 'getrefcount') else lambda o: -1
+try:
+    getrefcount = sys.getrefcount
+except AttributeError:
+    # PyPy
+    getrefcount = lambda o: len(gc.get_referents(o))
 
 class AbstractMemoryTests:
     source_bytes = b"abcdef"


More information about the pypy-commit mailing list