Skip to content

Commit 9fab79b

Browse files
Issue #26900: Excluded underscored names and other private API from limited API.
1 parent c16595e commit 9fab79b

21 files changed

+74
-15
lines changed

Doc/whatsnew/3.5.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2176,8 +2176,7 @@ New ``calloc`` functions were added:
21762176

21772177
* :c:func:`PyMem_RawCalloc`,
21782178
* :c:func:`PyMem_Calloc`,
2179-
* :c:func:`PyObject_Calloc`,
2180-
* :c:func:`_PyObject_GC_Calloc`.
2179+
* :c:func:`PyObject_Calloc`.
21812180

21822181
(Contributed by Victor Stinner in :issue:`21233`.)
21832182

Include/abstract.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ extern "C" {
77
#ifdef PY_SSIZE_T_CLEAN
88
#define PyObject_CallFunction _PyObject_CallFunction_SizeT
99
#define PyObject_CallMethod _PyObject_CallMethod_SizeT
10+
#ifndef Py_LIMITED_API
1011
#define _PyObject_CallMethodId _PyObject_CallMethodId_SizeT
12+
#endif /* !Py_LIMITED_API */
1113
#endif
1214

1315
/* Abstract Object Interface (many thanks to Jim Fulton) */
@@ -385,6 +387,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
385387
Python expression: o.method(args).
386388
*/
387389

390+
#ifndef Py_LIMITED_API
388391
PyAPI_FUNC(PyObject *) _PyObject_CallMethodId(PyObject *o,
389392
_Py_Identifier *method,
390393
const char *format, ...);
@@ -393,6 +396,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
393396
Like PyObject_CallMethod, but expect a _Py_Identifier* as the
394397
method name.
395398
*/
399+
#endif /* !Py_LIMITED_API */
396400

397401
PyAPI_FUNC(PyObject *) _PyObject_CallFunction_SizeT(PyObject *callable,
398402
const char *format,
@@ -401,10 +405,12 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
401405
const char *name,
402406
const char *format,
403407
...);
408+
#ifndef Py_LIMITED_API
404409
PyAPI_FUNC(PyObject *) _PyObject_CallMethodId_SizeT(PyObject *o,
405410
_Py_Identifier *name,
406411
const char *format,
407412
...);
413+
#endif /* !Py_LIMITED_API */
408414

409415
PyAPI_FUNC(PyObject *) PyObject_CallFunctionObjArgs(PyObject *callable,
410416
...);
@@ -420,9 +426,11 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
420426

421427
PyAPI_FUNC(PyObject *) PyObject_CallMethodObjArgs(PyObject *o,
422428
PyObject *method, ...);
429+
#ifndef Py_LIMITED_API
423430
PyAPI_FUNC(PyObject *) _PyObject_CallMethodIdObjArgs(PyObject *o,
424431
struct _Py_Identifier *method,
425432
...);
433+
#endif /* !Py_LIMITED_API */
426434

427435
/*
428436
Call the method named m of object o with a variable number of
@@ -1340,13 +1348,13 @@ PyAPI_FUNC(int) _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls);
13401348
PyAPI_FUNC(char *const *) _PySequence_BytesToCharpArray(PyObject* self);
13411349

13421350
PyAPI_FUNC(void) _Py_FreeCharPArray(char *const array[]);
1343-
#endif
13441351

13451352
/* For internal use by buffer API functions */
13461353
PyAPI_FUNC(void) _Py_add_one_to_index_F(int nd, Py_ssize_t *index,
13471354
const Py_ssize_t *shape);
13481355
PyAPI_FUNC(void) _Py_add_one_to_index_C(int nd, Py_ssize_t *index,
13491356
const Py_ssize_t *shape);
1357+
#endif /* !Py_LIMITED_API */
13501358

13511359

13521360
#ifdef __cplusplus

Include/ceval.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,9 @@ PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *);
179179

180180
PyAPI_FUNC(int) PyEval_ThreadsInitialized(void);
181181
PyAPI_FUNC(void) PyEval_InitThreads(void);
182+
#ifndef Py_LIMITED_API
182183
PyAPI_FUNC(void) _PyEval_FiniThreads(void);
184+
#endif /* !Py_LIMITED_API */
183185
PyAPI_FUNC(void) PyEval_AcquireLock(void);
184186
PyAPI_FUNC(void) PyEval_ReleaseLock(void);
185187
PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate);

Include/descrobject.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ PyAPI_DATA(PyTypeObject) PyMemberDescr_Type;
7878
PyAPI_DATA(PyTypeObject) PyMethodDescr_Type;
7979
PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type;
8080
PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
81+
#ifndef Py_LIMITED_API
8182
PyAPI_DATA(PyTypeObject) _PyMethodWrapper_Type;
83+
#endif /* Py_LIMITED_API */
8284

8385
PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
8486
PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);

Include/dictobject.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ PyAPI_FUNC(PyObject *) _PyDict_GetItem_KnownHash(PyObject *mp, PyObject *key,
7373
Py_hash_t hash);
7474
#endif
7575
PyAPI_FUNC(PyObject *) PyDict_GetItemWithError(PyObject *mp, PyObject *key);
76+
#ifndef Py_LIMITED_API
7677
PyAPI_FUNC(PyObject *) _PyDict_GetItemIdWithError(PyObject *dp,
7778
struct _Py_Identifier *key);
78-
#ifndef Py_LIMITED_API
7979
PyAPI_FUNC(PyObject *) PyDict_SetDefault(
8080
PyObject *mp, PyObject *key, PyObject *defaultobj);
8181
#endif
@@ -145,9 +145,13 @@ PyAPI_FUNC(int) PyDict_MergeFromSeq2(PyObject *d,
145145
int override);
146146

147147
PyAPI_FUNC(PyObject *) PyDict_GetItemString(PyObject *dp, const char *key);
148+
#ifndef Py_LIMITED_API
148149
PyAPI_FUNC(PyObject *) _PyDict_GetItemId(PyObject *dp, struct _Py_Identifier *key);
150+
#endif /* !Py_LIMITED_API */
149151
PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item);
152+
#ifndef Py_LIMITED_API
150153
PyAPI_FUNC(int) _PyDict_SetItemId(PyObject *dp, struct _Py_Identifier *key, PyObject *item);
154+
#endif /* !Py_LIMITED_API */
151155
PyAPI_FUNC(int) PyDict_DelItemString(PyObject *dp, const char *key);
152156

153157
#ifndef Py_LIMITED_API

Include/fileutils.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
extern "C" {
66
#endif
77

8-
PyAPI_FUNC(PyObject *) _Py_device_encoding(int);
9-
108
PyAPI_FUNC(wchar_t *) Py_DecodeLocale(
119
const char *arg,
1210
size_t *size);
@@ -17,6 +15,8 @@ PyAPI_FUNC(char*) Py_EncodeLocale(
1715

1816
#ifndef Py_LIMITED_API
1917

18+
PyAPI_FUNC(PyObject *) _Py_device_encoding(int);
19+
2020
#ifdef MS_WINDOWS
2121
struct _Py_stat_struct {
2222
unsigned long st_dev;
@@ -46,21 +46,18 @@ PyAPI_FUNC(int) _Py_fstat(
4646
PyAPI_FUNC(int) _Py_fstat_noraise(
4747
int fd,
4848
struct _Py_stat_struct *status);
49-
#endif /* Py_LIMITED_API */
5049

5150
PyAPI_FUNC(int) _Py_stat(
5251
PyObject *path,
5352
struct stat *status);
5453

55-
#ifndef Py_LIMITED_API
5654
PyAPI_FUNC(int) _Py_open(
5755
const char *pathname,
5856
int flags);
5957

6058
PyAPI_FUNC(int) _Py_open_noraise(
6159
const char *pathname,
6260
int flags);
63-
#endif
6461

6562
PyAPI_FUNC(FILE *) _Py_wfopen(
6663
const wchar_t *path,
@@ -107,7 +104,6 @@ PyAPI_FUNC(wchar_t*) _Py_wgetcwd(
107104
wchar_t *buf,
108105
size_t size);
109106

110-
#ifndef Py_LIMITED_API
111107
PyAPI_FUNC(int) _Py_get_inheritable(int fd);
112108

113109
PyAPI_FUNC(int) _Py_set_inheritable(int fd, int inheritable,

Include/import.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
extern "C" {
88
#endif
99

10+
#ifndef Py_LIMITED_API
1011
PyAPI_FUNC(void) _PyImportZip_Init(void);
12+
#endif /* !Py_LIMITED_API */
1113

1214
PyMODINIT_FUNC PyInit_imp(void);
1315
PyAPI_FUNC(long) PyImport_GetMagicNumber(void);

Include/intrcheck.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ extern "C" {
88
PyAPI_FUNC(int) PyOS_InterruptOccurred(void);
99
PyAPI_FUNC(void) PyOS_InitInterrupts(void);
1010
PyAPI_FUNC(void) PyOS_AfterFork(void);
11+
12+
#ifndef Py_LIMITED_API
1113
PyAPI_FUNC(int) _PyOS_IsMainThread(void);
1214

1315
#ifdef MS_WINDOWS
1416
/* windows.h is not included by Python.h so use void* instead of HANDLE */
1517
PyAPI_FUNC(void*) _PyOS_SigintEvent(void);
1618
#endif
19+
#endif /* !Py_LIMITED_API */
1720

1821
#ifdef __cplusplus
1922
}

Include/longobject.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,10 @@ PyAPI_FUNC(int) _PyLong_FormatAdvancedWriter(
204204
PyAPI_FUNC(unsigned long) PyOS_strtoul(const char *, char **, int);
205205
PyAPI_FUNC(long) PyOS_strtol(const char *, char **, int);
206206

207+
#ifndef Py_LIMITED_API
207208
/* For use by the gcd function in mathmodule.c */
208209
PyAPI_FUNC(PyObject *) _PyLong_GCD(PyObject *, PyObject *);
210+
#endif /* !Py_LIMITED_API */
209211

210212
#ifdef __cplusplus
211213
}

Include/modsupport.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ extern "C" {
1515
#define PyArg_Parse _PyArg_Parse_SizeT
1616
#define PyArg_ParseTuple _PyArg_ParseTuple_SizeT
1717
#define PyArg_ParseTupleAndKeywords _PyArg_ParseTupleAndKeywords_SizeT
18+
#ifndef Py_LIMITED_API
1819
#define PyArg_VaParse _PyArg_VaParse_SizeT
1920
#define PyArg_VaParseTupleAndKeywords _PyArg_VaParseTupleAndKeywords_SizeT
21+
#endif /* !Py_LIMITED_API */
2022
#define Py_BuildValue _Py_BuildValue_SizeT
2123
#define Py_VaBuildValue _Py_VaBuildValue_SizeT
2224
#else
25+
#ifndef Py_LIMITED_API
2326
PyAPI_FUNC(PyObject *) _Py_VaBuildValue_SizeT(const char *, va_list);
27+
#endif /* !Py_LIMITED_API */
2428
#endif
2529

2630
/* Due to a glitch in 3.2, the _SizeT versions weren't exported from the DLL. */

0 commit comments

Comments
 (0)