[pypy-svn] r74205 - in pypy/branch/cpython-extension/pypy/module/cpyext: . test
afa at codespeak.net
afa at codespeak.net
Wed Apr 28 23:50:08 CEST 2010
Author: afa
Date: Wed Apr 28 23:50:06 2010
New Revision: 74205
Modified:
pypy/branch/cpython-extension/pypy/module/cpyext/funcobject.py
pypy/branch/cpython-extension/pypy/module/cpyext/stubs.py
pypy/branch/cpython-extension/pypy/module/cpyext/test/test_funcobject.py
Log:
PyMethod_New
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/funcobject.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/funcobject.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/funcobject.py Wed Apr 28 23:50:06 2010
@@ -33,6 +33,15 @@
from pypy.module.cpyext.object import PyObject_dealloc
PyObject_dealloc(space, py_obj)
+ at cpython_api([PyObject, PyObject, PyObject], PyObject)
+def PyMethod_New(space, w_func, w_self, w_cls):
+ """Return a new method object, with func being any callable object; this is the
+ function that will be called when the method is called. If this method should
+ be bound to an instance, self should be the instance and class should be the
+ class of self, otherwise self should be NULL and class should be the
+ class which provides the unbound method."""
+ return Method(space, w_func, w_self, w_cls)
+
@cpython_api([PyObject], PyObject, borrowed=True)
def PyMethod_Function(space, w_method):
"""Return the function object associated with the method meth."""
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 23:50:06 2010
@@ -2324,15 +2324,6 @@
changes in your code for properly supporting 64-bit systems."""
raise NotImplementedError
- at cpython_api([PyObject, PyObject, PyObject], PyObject)
-def PyMethod_New(space, func, self, cls):
- """Return a new method object, with func being any callable object; this is the
- function that will be called when the method is called. If this method should
- be bound to an instance, self should be the instance and class should be the
- class of self, otherwise self should be NULL and class should be the
- class which provides the unbound method.."""
- raise NotImplementedError
-
@cpython_api([PyObject], PyObject, borrowed=True)
def PyMethod_Self(space, meth):
"""Return the instance associated with the method meth if it is bound, otherwise
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_funcobject.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/test_funcobject.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_funcobject.py Wed Apr 28 23:50:06 2010
@@ -27,3 +27,8 @@
w_function = space.getattr(w_method, space.wrap("im_func"))
assert space.is_w(api.PyMethod_Function(w_method), w_function)
+
+ w_class = space.getattr(w_method, space.wrap("im_class"))
+ w_self = space.getattr(w_method, space.wrap("im_self"))
+ w_method2 = api.PyMethod_New(w_function, w_self, w_class)
+ assert space.eq_w(w_method, w_method2)
More information about the Pypy-commit
mailing list