mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
Issue #1587: Added instancemethod wrapper for PyCFunctions. The Python C API
has gained a new type *PyInstanceMethod_Type* and the functions *PyInstanceMethod_Check(o)*, *PyInstanceMethod_New(func)* and *PyInstanceMethod_Function(im)*.
This commit is contained in:
parent
fc5aa9d0bc
commit
a3534a6ff5
4 changed files with 312 additions and 7 deletions
|
|
@ -2522,6 +2522,47 @@ There are a few functions specific to Python functions.
|
|||
Raises :exc:`SystemError` and returns ``-1`` on failure.
|
||||
|
||||
|
||||
.. _instancemethod-objects:
|
||||
|
||||
Instance Method Objects
|
||||
-----------------------
|
||||
|
||||
.. index:: object: instancemethod
|
||||
|
||||
An instance method is a wrapper for a :cdata:`PyCFunction` and the new way
|
||||
to bind a :cdata:`PyCFunction` to a class object. It replaces the former call
|
||||
:cfunc:`PyMethod_New(func, NULL, class)`.
|
||||
|
||||
|
||||
.. cvar:: PyTypeObject PyInstanceMethod_Type
|
||||
|
||||
This instance of :ctype:`PyTypeObject` represents the Python instance
|
||||
method type. It is not exposed to Python programs.
|
||||
|
||||
|
||||
.. cfunction:: int PyInstanceMethod_Check(PyObject *o)
|
||||
|
||||
Return true if *o* is an instance method object (has type
|
||||
:cdata:`PyInstanceMethod_Type`). The parameter must not be *NULL*.
|
||||
|
||||
|
||||
.. cfunction:: PyObject* PyInstanceMethod_New(PyObject *func)
|
||||
|
||||
Return a new instance method object, with *func* being any callable object
|
||||
*func* is is the function that will be called when the instance method is
|
||||
called.
|
||||
|
||||
|
||||
.. cfunction:: PyObject* PyInstanceMethod_Function(PyObject *im)
|
||||
|
||||
Return the function object associated with the instance method *im*.
|
||||
|
||||
|
||||
.. cfunction:: PyObject* PyInstanceMethod_GET_FUNCTION(PyObject *im)
|
||||
|
||||
Macro version of :cfunc:`PyInstanceMethod_Function` which avoids error checking.
|
||||
|
||||
|
||||
.. _method-objects:
|
||||
|
||||
Method Objects
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue