Skip to content

Commit 72f6c8c

Browse files
committed
gh-143869: Add PEP 757 functions to the limited API
1 parent f5685a2 commit 72f6c8c

File tree

7 files changed

+85
-39
lines changed

7 files changed

+85
-39
lines changed

Doc/data/stable_abi.dat

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

Include/cpython/longintrepr.h

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -138,45 +138,6 @@ _PyLong_CompactValue(const PyLongObject *op)
138138

139139
#define PyUnstable_Long_CompactValue _PyLong_CompactValue
140140

141-
142-
/* --- Import/Export API -------------------------------------------------- */
143-
144-
typedef struct PyLongLayout {
145-
uint8_t bits_per_digit;
146-
uint8_t digit_size;
147-
int8_t digits_order;
148-
int8_t digit_endianness;
149-
} PyLongLayout;
150-
151-
PyAPI_FUNC(const PyLongLayout*) PyLong_GetNativeLayout(void);
152-
153-
typedef struct PyLongExport {
154-
int64_t value;
155-
uint8_t negative;
156-
Py_ssize_t ndigits;
157-
const void *digits;
158-
// Member used internally, must not be used for other purpose.
159-
Py_uintptr_t _reserved;
160-
} PyLongExport;
161-
162-
PyAPI_FUNC(int) PyLong_Export(
163-
PyObject *obj,
164-
PyLongExport *export_long);
165-
PyAPI_FUNC(void) PyLong_FreeExport(
166-
PyLongExport *export_long);
167-
168-
169-
/* --- PyLongWriter API --------------------------------------------------- */
170-
171-
typedef struct PyLongWriter PyLongWriter;
172-
173-
PyAPI_FUNC(PyLongWriter*) PyLongWriter_Create(
174-
int negative,
175-
Py_ssize_t ndigits,
176-
void **digits);
177-
PyAPI_FUNC(PyObject*) PyLongWriter_Finish(PyLongWriter *writer);
178-
PyAPI_FUNC(void) PyLongWriter_Discard(PyLongWriter *writer);
179-
180141
#ifdef __cplusplus
181142
}
182143
#endif

Include/longobject.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,44 @@ PyAPI_FUNC(PyObject *) PyLong_FromString(const char *, char **, int);
166166
PyAPI_FUNC(unsigned long) PyOS_strtoul(const char *, char **, int);
167167
PyAPI_FUNC(long) PyOS_strtol(const char *, char **, int);
168168

169+
/* --- Import/Export API -------------------------------------------------- */
170+
171+
typedef struct PyLongLayout {
172+
uint8_t bits_per_digit;
173+
uint8_t digit_size;
174+
int8_t digits_order;
175+
int8_t digit_endianness;
176+
} PyLongLayout;
177+
178+
PyAPI_FUNC(const PyLongLayout*) PyLong_GetNativeLayout(void);
179+
180+
typedef struct PyLongExport {
181+
int64_t value;
182+
uint8_t negative;
183+
Py_ssize_t ndigits;
184+
const void *digits;
185+
// Member used internally, must not be used for other purpose.
186+
Py_uintptr_t _reserved;
187+
} PyLongExport;
188+
189+
PyAPI_FUNC(int) PyLong_Export(
190+
PyObject *obj,
191+
PyLongExport *export_long);
192+
PyAPI_FUNC(void) PyLong_FreeExport(
193+
PyLongExport *export_long);
194+
195+
196+
/* --- PyLongWriter API --------------------------------------------------- */
197+
198+
typedef struct PyLongWriter PyLongWriter;
199+
200+
PyAPI_FUNC(PyLongWriter*) PyLongWriter_Create(
201+
int negative,
202+
Py_ssize_t ndigits,
203+
void **digits);
204+
PyAPI_FUNC(PyObject*) PyLongWriter_Finish(PyLongWriter *writer);
205+
PyAPI_FUNC(void) PyLongWriter_Discard(PyLongWriter *writer);
206+
169207
#ifndef Py_LIMITED_API
170208
# define Py_CPYTHON_LONGOBJECT_H
171209
# include "cpython/longobject.h"

Lib/test/test_stable_abi_ctypes.py

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Added :c:func:`PyLong_GetNativeLayout`, :c:struct:`PyLongExport`,
2+
:c:func:`PyLong_Export`, :c:func:`PyLong_FreeExport`,
3+
:c:struct:`PyLongWriter`, :c:func:`PyLongWriter_Create`,
4+
:c:func:`PyLongWriter_Finish` and :c:func:`PyLongWriter_Discard` to the
5+
limited API.

Misc/stable_abi.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2664,3 +2664,24 @@
26642664
[function.Py_SET_SIZE]
26652665
# Before 3.15, this was a macro that accessed the PyObject member
26662666
added = '3.15'
2667+
[function.PyLong_GetNativeLayout]
2668+
added = '3.15'
2669+
[function.PyLong_Export]
2670+
added = '3.15'
2671+
[function.PyLong_FreeExport]
2672+
added = '3.15'
2673+
[function.PyLongWriter_Create]
2674+
added = '3.15'
2675+
[function.PyLongWriter_Finish]
2676+
added = '3.15'
2677+
[function.PyLongWriter_Discard]
2678+
added = '3.15'
2679+
[struct.PyLongWriter]
2680+
added = '3.15'
2681+
struct_abi_kind = 'opaque'
2682+
[struct.PyLongLayout]
2683+
added = '3.15'
2684+
struct_abi_kind = 'full-abi'
2685+
[struct.PyLongExport]
2686+
added = '3.15'
2687+
struct_abi_kind = 'members'

PC/python3dll.c

Lines changed: 6 additions & 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)