8000 Issue #26900: Excluded underscored names and other private API from l… · python/cpython@9fab79b · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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. */

Include/namespaceobject.h

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

10+
#ifndef Py_LIMITED_API
1011
PyAPI_DATA(PyTypeObject) _PyNamespace_Type;
1112

1213
PyAPI_FUNC(PyObject *) _PyNamespace_New(PyObject *kwds);
14+
#endif /* !Py_LIMITED_API */
1315

1416
#ifdef __cplusplus
1517
}

Include/object.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ typedef struct {
118118
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
119119
#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
120120

121+
#ifndef Py_LIMITED_API
121122
/********************* String Literals ****************************************/
122123
/* This structure helps managing static strings. The basic usage goes like this:
123124
Instead of doing
@@ -148,6 +149,8 @@ typedef struct _Py_Identifier {
148149
#define _Py_static_string(varname, value) static _Py_Identifier varname = _Py_static_string_init(value)
149150
#define _Py_IDENTIFIER(varname) _Py_static_string(PyId_##varname, #varname)
150151

152+
#endif /* !Py_LIMITED_API */
153+
151154
/*
152155
Type objects contain a string containing the type name (to help somewhat
153156
in debugging), the allocation parameters (see PyObject_New() and
@@ -512,8 +515,8 @@ PyAPI_FUNC(PyObject *) _PyType_GetTextSignatureFromInternalDoc(const char *, con
512515
#endif
513516

514517
/* Generic operations on objects */
515-
struct _Py_Identifier;
516518
#ifndef Py_LIMITED_API
519+
struct _Py_Identifier;
517520
PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int);
518521
PyAPI_FUNC(void) _Py_BreakPoint(void);
519522
PyAPI_FUNC(void) _PyObject_Dump(PyObject *);
@@ -530,11 +533,11 @@ PyAPI_FUNC(int) PyObject_HasAttrString(PyObject *, const char *);
530533
PyAPI_FUNC(PyObject *) PyObject_GetAttr(PyObject *, PyObject *);
531534
PyAPI_FUNC(int) PyObject_SetAttr(PyObject *, PyObject *, PyObject *);
532535
PyAPI_FUNC(int) PyObject_HasAttr(PyObject *, PyObject *);
536+
#ifndef Py_LIMITED_API
533537
PyAPI_FUNC(int) _PyObject_IsAbstract(PyObject *);
534538
PyAPI_FUNC(PyObject *) _PyObject_GetAttrId(PyObject *, struct _Py_Identifier *);
535539
PyAPI_FUNC(int) _PyObject_SetAttrId(PyObject *, struct _Py_Identifier *, PyObject *);
536540
PyAPI_FUNC(int) _PyObject_HasAttrId(PyObject *, struct _Py_Identifier *);
537-
#ifndef Py_LIMITED_API
538541
PyAPI_FUNC(PyObject **) _PyObject_GetDictPtr(PyObject *);
539542
#endif
540543
PyAPI_FUNC(PyObject *) PyObject_SelfIter(PyObject *);
@@ -557,13 +560,15 @@ PyAPI_FUNC(void) PyObject_CallFinalizer(PyObject *);
557560
PyAPI_FUNC(int) PyObject_CallFinalizerFromDealloc(PyObject *);
558561
#endif
559562

563+
#ifndef Py_LIMITED_API
560564
/* Same as PyObject_Generic{Get,Set}Attr, but passing the attributes
561565
dict as the last parameter. */
562566
PyAPI_FUNC(PyObject *)
563567
_PyObject_GenericGetAttrWithDict(PyObject *, PyObject *, PyObject *);
564568
PyAPI_FUNC(int)
565569
_PyObject_GenericSetAttrWithDict(PyObject *, PyObject *,
566570
PyObject *, PyObject *);
571+
#endif /* !Py_LIMITED_API */
567572

568573
/* Helper to look up a builtin object */
569574
#ifndef Py_LIMITED_API
@@ -888,8 +893,10 @@ they can have object code that is not dependent on Python compilation flags.
888893
PyAPI_FUNC(void) Py_IncRef(PyObject *);
889894
PyAPI_FUNC(void) Py_DecRef(PyObject *);
890895

896+
#ifndef Py_LIMITED_API
891897
PyAPI_DATA(PyTypeObject) _PyNone_Type;
892898
PyAPI_DATA(PyTypeObject) _PyNotImplemented_Type;
899+
#endif /* !Py_LIMITED_API */
893900

894901
/*
895902
_Py_NoneStruct is an object of undefined type which can be used in contexts
@@ -922,10 +929,12 @@ PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */
922929
#define Py_GT 4
923930
#define Py_GE 5
924931

932+
#ifndef Py_LIMITED_API
925933
/* Maps Py_LT to Py_GT, ..., Py_GE to Py_LE.
926934
* Defined in object.c.
927935
*/
928936
PyAPI_DATA(int) _Py_SwappedOp[];
937+
#endif /* !Py_LIMITED_API */
929938

930939

931940
/*
@@ -1022,12 +1031,14 @@ chain of N deallocations is broken into N / PyTrash_UNWIND_LEVEL pieces,
10221031
with the call stack never exceeding a depth of PyTrash_UNWIND_LEVEL.
10231032
*/
10241033

1034+
#ifndef Py_LIMITED_API
10251035
/* This is the old private API, invoked by the macros before 3.2.4.
10261036
Kept for binary compatibility of extensions using the stable ABI. */
10271037
PyAPI_FUNC(void) _PyTrash_deposit_object(PyObject*);
10281038
PyAPI_FUNC(void) _PyTrash_destroy_chain(void);
10291039
PyAPI_DATA(int) _PyTrash_delete_nesting;
10301040
PyAPI_DATA(PyObject *) _PyTrash_delete_later;
1041+
#endif /* !Py_LIMITED_API */
10311042

10321043
/* The new thread-safe private API, invoked by the macros below. */
10331044
PyAPI_FUNC(void) _PyTrash_thread_deposit_object(PyObject*);

Include/objimpl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,10 @@ PyAPI_FUNC(void *) PyObject_Calloc(size_t nelem, size_t elsize);
9999
PyAPI_FUNC(void *) PyObject_Realloc(void *ptr, size_t new_size);
100100
PyAPI_FUNC(void) PyObject_Free(void *ptr);
101101

102+
#ifndef Py_LIMITED_API
102103
/* This function returns the number of allocated memory blocks, regardless of size */
103104
PyAPI_FUNC(Py_ssize_t) _Py_GetAllocatedBlocks(void);
105+
#endif /* !Py_LIMITED_API */
104106

105107
/* Macros */
106108
#ifdef WITH_PYMALLOC
@@ -323,8 +325,10 @@ extern PyGC_Head *_PyGC_generation0;
323325
(!PyTuple_CheckExact(obj) || _PyObject_GC_IS_TRACKED(obj)))
324326
#endif /* Py_LIMITED_API */
325327

328+
#ifndef Py_LIMITED_API
326329
PyAPI_FUNC(PyObject *) _PyObject_GC_Malloc(size_t size);
327330
PyAPI_FUNC(PyObject *) _PyObject_GC_Calloc(size_t size);
331+
#endif /* !Py_LIMITED_API */
328332
PyAPI_FUNC(PyObject *) _PyObject_GC_New(PyTypeObject *);
329333
PyAPI_FUNC(PyVarObject *) _PyObject_GC_NewVar(PyTypeObject *, Py_ssize_t);
330334
PyAPI_FUNC(void) PyObject_GC_Track(void *);

Include/pygetopt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ PyAPI_DATA(int) _PyOS_optind;
1111
PyAPI_DATA(wchar_t *) _PyOS_optarg;
1212

1313
PyAPI_FUNC(void) _PyOS_ResetGetOpt(void);
14-
#endif
1514

1615
PyAPI_FUNC(int) _PyOS_GetOpt(int argc, wchar_t **argv, wchar_t *optstring);
16+
#endif /* !Py_LIMITED_API */
1717

1818
#ifdef __cplusplus
1919
}

Include/pylifecycle.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,11 @@ typedef void (*PyOS_sighandler_t)(int);
117117
PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int);
118118
PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t);
119119

120+
#ifndef Py_LIMITED_API
120121
/* Random */
121122
PyAPI_FUNC(int) _PyOS_URandom(void *buffer, Py_ssize_t size);
122123
PyAPI_FUNC(int) _PyOS_URandomNonblock(void *buffer, Py_ssize_t size);
124+
#endif /* !Py_LIMITED_API */
123125

124126
#ifdef __cplusplus
125127
}

0 commit comments

Comments
 (0)
0