[pypy-svn] r8867 - in pypy/dist: lib-python-2.3.4/test pypy/module
ac at codespeak.net
ac at codespeak.net
Fri Feb 4 14:35:43 CET 2005
Author: ac
Date: Fri Feb 4 14:35:43 2005
New Revision: 8867
Modified:
pypy/dist/lib-python-2.3.4/test/conftest.py
pypy/dist/pypy/module/sysinterp.py
pypy/dist/pypy/module/sysmodule.py
Log:
Implement a primitive sys.getrefcount() (It gets test_sys to work).
Modified: pypy/dist/lib-python-2.3.4/test/conftest.py
==============================================================================
--- pypy/dist/lib-python-2.3.4/test/conftest.py (original)
+++ pypy/dist/lib-python-2.3.4/test/conftest.py Fri Feb 4 14:35:43 2005
@@ -35,6 +35,7 @@
'test_compile.py',
'test_operator.py',
'test_heapq.py',
+'test_sys.py',
)
working_outputtests = (
Modified: pypy/dist/pypy/module/sysinterp.py
==============================================================================
--- pypy/dist/pypy/module/sysinterp.py (original)
+++ pypy/dist/pypy/module/sysinterp.py Fri Feb 4 14:35:43 2005
@@ -188,3 +188,15 @@
def getdefaultencoding():
"""getdefaultencoding() -> return the default encoding used for UNICODE"""
return space.wrap(cpy_sys.getdefaultencoding())
+
+def getrefcount(w_obj):
+ """getrefcount(object) -> integer
+
+Return the reference count of object. The count returned is generally
+one higher than you might expect, because it includes the (temporary)
+reference as an argument to getrefcount().
+"""
+ # From the results i get when using this i need to apply a fudge
+ # value of 6 to get results comparable to cpythons. /Arre
+ return space.wrap(cpy_sys.getrefcount(w_obj) - 6)
+
Modified: pypy/dist/pypy/module/sysmodule.py
==============================================================================
--- pypy/dist/pypy/module/sysmodule.py (original)
+++ pypy/dist/pypy/module/sysmodule.py Fri Feb 4 14:35:43 2005
@@ -20,7 +20,7 @@
from __interplevel__ import _getframe, exc_info, exc_clear, pypy_getudir
from __interplevel__ import getrecursionlimit, setrecursionlimit
from __interplevel__ import getcheckinterval, setcheckinterval
-from __interplevel__ import getdefaultencoding
+from __interplevel__ import getdefaultencoding, getrefcount
# Dummy
executable = 'py.py'
More information about the Pypy-commit
mailing list