[pypy-svn] r74072 - in pypy/branch/cpython-extension/pypy/module/cpyext: . test
afa at codespeak.net
afa at codespeak.net
Mon Apr 26 14:39:21 CEST 2010
Author: afa
Date: Mon Apr 26 14:39:19 2010
New Revision: 74072
Modified:
pypy/branch/cpython-extension/pypy/module/cpyext/methodobject.py
pypy/branch/cpython-extension/pypy/module/cpyext/stubs.py
pypy/branch/cpython-extension/pypy/module/cpyext/test/test_methodobject.py
Log:
PyMethod_Check, PyCFunction_Check
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/methodobject.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/methodobject.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/methodobject.py Mon Apr 26 14:39:19 2010
@@ -11,7 +11,7 @@
from pypy.module.cpyext.api import (
generic_cpy_call, cpython_api, PyObject, cpython_struct, METH_KEYWORDS,
METH_O, CONST_STRING, METH_CLASS, METH_STATIC, METH_COEXIST, METH_NOARGS,
- METH_VARARGS)
+ METH_VARARGS, build_type_checkers)
from pypy.module.cpyext.state import State
from pypy.module.cpyext.pyerrors import PyErr_Occurred
from pypy.rlib.objectmodel import we_are_translated
@@ -89,6 +89,8 @@
def descr_method_repr(self):
return self.getrepr(self.space, "built-in method '%s' of '%s' object" % (self.name, self.w_objclass.getname(self.space, '?')))
+PyMethod_Check, PyMethod_CheckExact = build_type_checkers("Method", W_PyCMethodObject)
+PyCFunction_Check, PyCFunction_CheckExact = build_type_checkers("CFunction", W_PyCFunctionObject)
class W_PyCWrapperObject(Wrappable):
def __init__(self, space, pto, method_name, wrapper_func, wrapper_func_kwds,
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 Mon Apr 26 14:39:19 2010
@@ -3555,12 +3555,6 @@
"""Same as PyMem_Free()."""
raise NotImplementedError
- at cpython_api([PyObject], rffi.INT_real)
-def PyMethod_Check(space, o):
- """Return true if o is a method object (has type PyMethod_Type). The
- parameter must not be NULL."""
- raise NotImplementedError
-
@cpython_api([PyObject, PyObject, PyObject], PyObject)
def PyMethod_New(space, func, self, class):
"""Return a new method object, with func being any callable object; this is the
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_methodobject.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/test_methodobject.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_methodobject.py Mon Apr 26 14:39:19 2010
@@ -34,6 +34,16 @@
}
'''
),
+ ('isCFunction', 'METH_O',
+ '''
+ if(PyCFunction_Check(args)) {
+ Py_RETURN_TRUE;
+ }
+ else {
+ Py_RETURN_FALSE;
+ }
+ '''
+ ),
])
assert mod.getarg_O(1) == 1
raises(TypeError, mod.getarg_O)
@@ -46,3 +56,5 @@
assert mod.getarg_OLD(1) == 1
assert mod.getarg_OLD() is None
assert mod.getarg_OLD(1, 2) == (1, 2)
+
+ assert mod.isCFunction(mod.getarg_O)
More information about the Pypy-commit
mailing list