[pypy-svn] pypy default: Write a stub for sys.getsizeof().

arigo commits-noreply at bitbucket.org
Thu Jan 20 18:21:25 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r41052:0924ad5b7b54
Date: 2011-01-20 17:52 +0100
http://bitbucket.org/pypy/pypy/changeset/0924ad5b7b54/

Log:	Write a stub for sys.getsizeof().

diff --git a/pypy/module/sys/__init__.py b/pypy/module/sys/__init__.py
--- a/pypy/module/sys/__init__.py
+++ b/pypy/module/sys/__init__.py
@@ -56,6 +56,7 @@
         'setprofile'            : 'vm.setprofile',
         'getprofile'            : 'vm.getprofile',
         'call_tracing'          : 'vm.call_tracing',
+        'getsizeof'             : 'vm.getsizeof',
         
         'executable'            : 'space.wrap("py.py")', 
         'api_version'           : 'version.get_api_version(space)',

diff --git a/pypy/module/sys/vm.py b/pypy/module/sys/vm.py
--- a/pypy/module/sys/vm.py
+++ b/pypy/module/sys/vm.py
@@ -2,7 +2,7 @@
 Implementation of interpreter-level 'sys' routines.
 """
 from pypy.interpreter.error import OperationError
-from pypy.interpreter.gateway import ObjSpace
+from pypy.interpreter.gateway import ObjSpace, NoneNotWrapped
 from pypy.rlib.runicode import MAXUNICODE
 from pypy.rlib import jit
 import sys
@@ -154,3 +154,10 @@
     from pypy.module._rawffi.interp_rawffi import W_CDLL, RawCDLL
     cdll = RawCDLL(handle)
     return space.wrap(W_CDLL(space, "python api", cdll))
+
+def getsizeof(space, w_object, w_default=NoneNotWrapped):
+    """Not implemented on PyPy."""
+    if w_default is None:
+        raise OperationError(space.w_TypeError,
+            space.wrap("sys.getsizeof() not implemented on PyPy"))
+    return w_default


More information about the Pypy-commit mailing list