Skip to content

Commit fac62e3

Browse files
committed
gh-155588: Add PyMethod_New to the stable ABI / limited API
See: capi-workgroup/decisions#108
1 parent f879f0d commit fac62e3

8 files changed

Lines changed: 35 additions & 1 deletion

File tree

Doc/data/stable_abi.dat

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Doc/whatsnew/3.16.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,8 @@ C API changes
872872
New features
873873
------------
874874

875-
* TODO
875+
* Add :c:func:`PyMethod_New` function to the limited C API.
876+
(Contributed by Nicolas Trangez in :gh:`155588`.)
876877

877878
Porting to Python 3.16
878879
----------------------

Include/Python.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ __pragma(warning(disable: 4201))
104104
#include "moduleobject.h"
105105
#include "cpython/monitoring.h"
106106
#include "cpython/funcobject.h"
107+
#include "classobject.h"
107108
#include "cpython/classobject.h"
108109
#include "fileobject.h"
109110
#include "pycapsule.h"

Include/classobject.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* Limited C API of PyMethod API
2+
*/
3+
4+
#ifndef Py_CLASSOBJECT_H
5+
#define Py_CLASSOBJECT_H
6+
7+
#ifdef __cplusplus
8+
extern "C" {
9+
#endif
10+
11+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03100000
12+
/* Return a new method object, with `func` being any callable object and
13+
* `self` the instance the method should be bound.
14+
*
15+
* `func` is the function that will be called when the method is called.
16+
* `self` must not be NULL.
17+
*/
18+
PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *);
19+
#endif
20+
21+
#ifdef __cplusplus
22+
}
23+
#endif
24+
#endif /* !Py_CLASSOBJECT_H */

Lib/test/test_stable_abi_ctypes.py

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add :c:func:`PyObject_CallFinalizerFromDealloc` function to the limited C
2+
API. Patch by Nicolas Trangez.

Misc/stable_abi.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2832,3 +2832,6 @@
28322832

28332833
[function.PyObject_CallFinalizerFromDealloc]
28342834
added = '3.15'
2835+
2836+
[function.PyMethod_New]
2837+
added = '3.16'

PC/python3dll.c

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)