[pypy-svn] r79014 - pypy/branch/rlist-jit/pypy/module/cpyext

arigo at codespeak.net arigo at codespeak.net
Thu Nov 11 18:26:39 CET 2010


Author: arigo
Date: Thu Nov 11 18:26:38 2010
New Revision: 79014

Modified:
   pypy/branch/rlist-jit/pypy/module/cpyext/slotdefs.py
   pypy/branch/rlist-jit/pypy/module/cpyext/tupleobject.py
Log:
Fix.


Modified: pypy/branch/rlist-jit/pypy/module/cpyext/slotdefs.py
==============================================================================
--- pypy/branch/rlist-jit/pypy/module/cpyext/slotdefs.py	(original)
+++ pypy/branch/rlist-jit/pypy/module/cpyext/slotdefs.py	Thu Nov 11 18:26:38 2010
@@ -28,14 +28,14 @@
 
 def check_num_args(space, ob, n):
     from pypy.module.cpyext.tupleobject import PyTuple_CheckExact, \
-            PyTuple_GET_SIZE
+            _PyTuple_Size_Fast
     if not PyTuple_CheckExact(space, ob):
         raise OperationError(space.w_SystemError,
             space.wrap("PyArg_UnpackTuple() argument list is not a tuple"))
-    if n == PyTuple_GET_SIZE(space, ob):
+    if n == _PyTuple_Size_Fast(space, ob):
         return
     raise operationerrfmt(space.w_TypeError,
-        "expected %d arguments, got %d", n, PyTuple_GET_SIZE(space, ob))
+        "expected %d arguments, got %d", n, _PyTuple_Size_Fast(space, ob))
 
 def wrap_init(space, w_self, w_args, func, w_kwargs):
     func_init = rffi.cast(initproc, func)

Modified: pypy/branch/rlist-jit/pypy/module/cpyext/tupleobject.py
==============================================================================
--- pypy/branch/rlist-jit/pypy/module/cpyext/tupleobject.py	(original)
+++ pypy/branch/rlist-jit/pypy/module/cpyext/tupleobject.py	Thu Nov 11 18:26:38 2010
@@ -123,6 +123,13 @@
         return borrow_from(w_t, w_obj)
 
 @cpython_api([PyObject], Py_ssize_t, error=-1)
+def _PyTuple_Size_Fast(space, ref):
+    # custom version: it's not a macro, so it can be called from other .py
+    # files; but it doesn't include PyTuple_Check()
+    ref_tup = rffi.cast(PyTupleObject, ref)
+    return ref_tup.c_size
+
+ at cpython_api([PyObject], Py_ssize_t, error=-1)
 def PyTuple_Size(space, ref):
     """Take a pointer to a tuple object, and return the size of that tuple."""
     # XXX do PyTuple_Check, without forcing ref as an interpreter object



More information about the Pypy-commit mailing list