[pypy-svn] r74179 - in pypy/branch/cpython-extension/pypy/module/cpyext: . test

afa at codespeak.net afa at codespeak.net
Wed Apr 28 16:44:46 CEST 2010


Author: afa
Date: Wed Apr 28 16:44:45 2010
New Revision: 74179

Modified:
   pypy/branch/cpython-extension/pypy/module/cpyext/object.py
   pypy/branch/cpython-extension/pypy/module/cpyext/stubs.py
   pypy/branch/cpython-extension/pypy/module/cpyext/test/test_object.py
Log:
PyObject_Type


Modified: pypy/branch/cpython-extension/pypy/module/cpyext/object.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/object.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/object.py	Wed Apr 28 16:44:45 2010
@@ -166,6 +166,17 @@
     return from_ref(space, rffi.cast(PyObject, op)) # XXX likewise
 
 @cpython_api([PyObject], PyObject)
+def PyObject_Type(space, w_obj):
+    """When o is non-NULL, returns a type object corresponding to the object type
+    of object o. On failure, raises SystemError and returns NULL.  This
+    is equivalent to the Python expression type(o). This function increments the
+    reference count of the return value. There's really no reason to use this
+    function instead of the common expression o->ob_type, which returns a
+    pointer of type PyTypeObject*, except when the incremented reference
+    count is needed."""
+    return space.type(w_obj)
+
+ at cpython_api([PyObject], PyObject)
 def PyObject_Str(space, w_obj):
     return space.str(w_obj)
 

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/stubs.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/stubs.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/stubs.py	Wed Apr 28 16:44:45 2010
@@ -2836,27 +2836,6 @@
     raise NotImplementedError
 
 @cpython_api([PyObject], PyObject, borrowed=True)
-def PyMethod_Class(space, meth):
-    """Return the class object from which the method meth was created; if this was
-    created from an instance, it will be the class of the instance."""
-    raise NotImplementedError
-
- at cpython_api([PyObject], PyObject, borrowed=True)
-def PyMethod_GET_CLASS(space, meth):
-    """Macro version of PyMethod_Class() which avoids error checking."""
-    raise NotImplementedError
-
- at cpython_api([PyObject], PyObject, borrowed=True)
-def PyMethod_Function(space, meth):
-    """Return the function object associated with the method meth."""
-    raise NotImplementedError
-
- at cpython_api([PyObject], PyObject, borrowed=True)
-def PyMethod_GET_FUNCTION(space, meth):
-    """Macro version of PyMethod_Function() which avoids error checking."""
-    raise NotImplementedError
-
- at cpython_api([PyObject], PyObject, borrowed=True)
 def PyMethod_Self(space, meth):
     """Return the instance associated with the method meth if it is bound, otherwise
     return NULL."""
@@ -3109,21 +3088,6 @@
     """
     raise NotImplementedError
 
- at cpython_api([PyObject], PyObject)
-def PyObject_Type(space, o):
-    """
-    
-    
-    
-    When o is non-NULL, returns a type object corresponding to the object type
-    of object o. On failure, raises SystemError and returns NULL.  This
-    is equivalent to the Python expression type(o). This function increments the
-    reference count of the return value. There's really no reason to use this
-    function instead of the common expression o->ob_type, which returns a
-    pointer of type PyTypeObject*, except when the incremented reference
-    count is needed."""
-    raise NotImplementedError
-
 @cpython_api([PyObject, PyObject, PyObject], rffi.INT_real, error=-1)
 def PyObject_SetItem(space, o, key, v):
     """Map the object key to the value v.  Returns -1 on failure.  This is the

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_object.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/test_object.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_object.py	Wed Apr 28 16:44:45 2010
@@ -164,3 +164,6 @@
         assert (api.PyObject_Hash(space.wrap([])) == -1 and
             api.PyErr_Occurred() is space.w_TypeError)
         api.PyErr_Clear()
+
+    def test_type(self, space, api):
+        assert api.PyObject_Type(space.wrap(72)) is space.w_int



More information about the Pypy-commit mailing list