Skip to content

Commit b4d5a5c

Browse files
authored
bpo-39583: Remove superfluous "extern C" bits from Include/cpython/*.h (GH-18413)
1 parent cbe1296 commit b4d5a5c

20 files changed

+2
-151
lines changed

Include/cpython/abstract.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
# error "this header file must not be included directly"
33
#endif
44

5-
#ifdef __cplusplus
6-
extern "C" {
7-
#endif
8-
95
/* === Object Protocol ================================================== */
106

117
#ifdef PY_SSIZE_T_CLEAN
@@ -380,8 +376,4 @@ PyAPI_FUNC(void) _Py_add_one_to_index_C(int nd, Py_ssize_t *index,
380376
PyAPI_FUNC(int) _Py_convert_optional_to_ssize_t(PyObject *, void *);
381377

382378
/* Same as PyNumber_Index but can return an instance of a subclass of int. */
383-
PyAPI_FUNC(PyObject *) _PyNumber_Index(PyObject *o);
384-
385-
#ifdef __cplusplus
386-
}
387-
#endif
379+
PyAPI_FUNC(PyObject *) _PyNumber_Index(PyObject *o);

Include/cpython/ceval.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
# error "this header file must not be included directly"
33
#endif
44

5-
#ifdef __cplusplus
6-
extern "C" {
7-
#endif
8-
95
PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
106
PyAPI_DATA(int) _PyEval_SetProfile(PyThreadState *tstate, Py_tracefunc func, PyObject *arg);
117
PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
@@ -32,7 +28,3 @@ PyAPI_FUNC(Py_ssize_t) _PyEval_RequestCodeExtraIndex(freefunc);
3228

3329
PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *);
3430
PyAPI_FUNC(int) _PyEval_SliceIndexNotNone(PyObject *, Py_ssize_t *);
35-
36-
#ifdef __cplusplus
37-
}
38-
#endif

Include/cpython/dictobject.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
# error "this header file must not be included directly"
33
#endif
44

5-
#ifdef __cplusplus
6-
extern "C" {
7-
#endif
8-
95
typedef struct _dictkeysobject PyDictKeysObject;
106

117
/* The ma_values pointer is NULL for a combined table
@@ -86,7 +82,3 @@ typedef struct {
8682

8783
PyAPI_FUNC(PyObject *) _PyDictView_New(PyObject *, PyTypeObject *);
8884
PyAPI_FUNC(PyObject *) _PyDictView_Intersect(PyObject* self, PyObject *other);
89-
90-
#ifdef __cplusplus
91-
}
92-
#endif

Include/cpython/fileobject.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
# error "this header file must not be included directly"
33
#endif
44

5-
#ifdef __cplusplus
6-
extern "C" {
7-
#endif
8-
95
PyAPI_FUNC(char *) Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *);
106

117
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000
@@ -26,7 +22,3 @@ typedef PyObject * (*Py_OpenCodeHookFunction)(PyObject *, void *);
2622
PyAPI_FUNC(PyObject *) PyFile_OpenCode(const char *utf8path);
2723
PyAPI_FUNC(PyObject *) PyFile_OpenCodeObject(PyObject *path);
2824
PyAPI_FUNC(int) PyFile_SetOpenCodeHook(Py_OpenCodeHookFunction hook, void *userData);
29-
30-
#ifdef __cplusplus
31-
}
32-
#endif

Include/cpython/frameobject.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
# error "this header file must not be included directly"
55
#endif
66

7-
#ifdef __cplusplus
8-
extern "C" {
9-
#endif
10-
117
typedef struct {
128
int b_type; /* what kind of block this is */
139
int b_handler; /* where to jump to find handler */
@@ -78,7 +74,3 @@ PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *);
7874
PyAPI_FUNC(void) _PyFrame_DebugMallocStats(FILE *out);
7975

8076
PyAPI_FUNC(PyFrameObject *) PyFrame_GetBack(PyFrameObject *frame);
81-
82-
#ifdef __cplusplus
83-
}
84-
#endif

Include/cpython/import.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
# error "this header file must not be included directly"
33
#endif
44

5-
#ifdef __cplusplus
6-
extern "C" {
7-
#endif
8-
95
PyMODINIT_FUNC PyInit__imp(void);
106

117
PyAPI_FUNC(int) _PyImport_IsInitialized(PyInterpreterState *);
@@ -44,7 +40,3 @@ struct _frozen {
4440
collection of frozen modules: */
4541

4642
PyAPI_DATA(const struct _frozen *) PyImport_FrozenModules;
47-
48-
#ifdef __cplusplus
49-
}
50-
#endif

Include/cpython/initconfig.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#ifndef Py_PYCORECONFIG_H
22
#define Py_PYCORECONFIG_H
33
#ifndef Py_LIMITED_API
4-
#ifdef __cplusplus
5-
extern "C" {
6-
#endif
74

85
/* --- PyStatus ----------------------------------------------- */
96

@@ -438,8 +435,5 @@ PyAPI_FUNC(PyStatus) PyConfig_SetWideStringList(PyConfig *config,
438435
PyWideStringList *list,
439436
Py_ssize_t length, wchar_t **items);
440437

441-
#ifdef __cplusplus
442-
}
443-
#endif
444438
#endif /* !Py_LIMITED_API */
445439
#endif /* !Py_PYCORECONFIG_H */

Include/cpython/interpreteridobject.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,10 @@
22
# error "this header file must not be included directly"
33
#endif
44

5-
#ifdef __cplusplus
6-
extern "C" {
7-
#endif
8-
95
/* Interpreter ID Object */
106

117
PyAPI_DATA(PyTypeObject) _PyInterpreterID_Type;
128

139
PyAPI_FUNC(PyObject *) _PyInterpreterID_New(int64_t);
1410
PyAPI_FUNC(PyObject *) _PyInterpreterState_GetIDObject(PyInterpreterState *);
1511
PyAPI_FUNC(PyInterpreterState *) _PyInterpreterID_LookUp(PyObject *);
16-
17-
#ifdef __cplusplus
18-
}
19-
#endif

Include/cpython/listobject.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
# error "this header file must not be included directly"
33
#endif
44

5-
#ifdef __cplusplus
6-
extern "C" {
7-
#endif
8-
95
typedef struct {
106
PyObject_VAR_HEAD
117
/* Vector of pointers to list elements. list[0] is ob_item[0], etc. */
@@ -37,7 +33,3 @@ PyAPI_FUNC(void) _PyList_DebugMallocStats(FILE *out);
3733
#define PyList_SET_ITEM(op, i, v) (_PyList_CAST(op)->ob_item[i] = (v))
3834
#define PyList_GET_SIZE(op) Py_SIZE(_PyList_CAST(op))
3935
#define _PyList_ITEMS(op) (_PyList_CAST(op)->ob_item)
40-
41-
#ifdef __cplusplus
42-
}
43-
#endif

Include/cpython/object.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
# error "this header file must not be included directly"
33
#endif
44

5-
#ifdef __cplusplus
6-
extern "C" {
7-
#endif
8-
95
PyAPI_FUNC(void) _Py_NewReference(PyObject *op);
106

117
#ifdef Py_TRACE_REFS
@@ -548,7 +544,3 @@ PyAPI_FUNC(void) _PyTrash_end(struct _ts *tstate);
548544
* unconditionally */
549545
#define Py_TRASHCAN_SAFE_BEGIN(op) Py_TRASHCAN_BEGIN_CONDITION(op, 1)
550546
#define Py_TRASHCAN_SAFE_END(op) Py_TRASHCAN_END
551-
552-
#ifdef __cplusplus
553-
}
554-
#endif

Include/cpython/objimpl.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
# error "this header file must not be included directly"
33
#endif
44

5-
#ifdef __cplusplus
6-
extern "C" {
7-
#endif
8-
95
#define _PyObject_SIZE(typeobj) ( (typeobj)->tp_basicsize )
106

117
/* _PyObject_VAR_SIZE returns the number of bytes (as size_t) allocated for a
@@ -139,7 +135,3 @@ PyAPI_FUNC(PyObject *) _PyObject_GC_Calloc(size_t size);
139135
#define PyType_SUPPORTS_WEAKREFS(t) ((t)->tp_weaklistoffset > 0)
140136

141137
PyAPI_FUNC(PyObject **) PyObject_GET_WEAKREFS_LISTPTR(PyObject *op);
142-
143-
#ifdef __cplusplus
144-
}
145-
#endif

Include/cpython/pyerrors.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
# error "this header file must not be included directly"
33
#endif
44

5-
#ifdef __cplusplus
6-
extern "C" {
7-
#endif
8-
95
/* Error objects */
106

117
/* PyException_HEAD defines the initial segment of every exception class. */
@@ -188,7 +184,3 @@ PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalErrorFormat(
188184
...);
189185

190186
#define Py_FatalError(message) _Py_FatalErrorFunc(__func__, message)
191-
192-
#ifdef __cplusplus
193-
}
194-
#endif

Include/cpython/pylifecycle.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
# error "this header file must not be included directly"
33
#endif
44

5-
#ifdef __cplusplus
6-
extern "C" {
7-
#endif
8-
95
/* Only used by applications that embed the interpreter and need to
106
* override the standard encoding determination mechanism
117
*/
@@ -66,7 +62,3 @@ PyAPI_FUNC(int) _Py_LegacyLocaleDetected(int warn);
6662
PyAPI_FUNC(char *) _Py_SetLocaleFromEnv(int category);
6763

6864
PyAPI_FUNC(PyThreadState *) _Py_NewInterpreter(int isolated_subinterpreter);
69-
70-
#ifdef __cplusplus
71-
}
72-
#endif

Include/cpython/pymem.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
# error "this header file must not be included directly"
33
#endif
44

5-
#ifdef __cplusplus
6-
extern "C" {
7-
#endif
8-
95
PyAPI_FUNC(void *) PyMem_RawMalloc(size_t size);
106
PyAPI_FUNC(void *) PyMem_RawCalloc(size_t nelem, size_t elsize);
117
PyAPI_FUNC(void *) PyMem_RawRealloc(void *ptr, size_t new_size);
@@ -102,7 +98,3 @@ PyAPI_FUNC(void) PyMem_SetAllocator(PyMemAllocatorDomain domain,
10298
10399
The function does nothing if Python is not compiled is debug mode. */
104100
PyAPI_FUNC(void) PyMem_SetupDebugHooks(void);
105-
106-
#ifdef __cplusplus
107-
}
108-
#endif

Include/cpython/pystate.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
# error "this header file must not be included directly"
33
#endif
44

5-
#ifdef __cplusplus
6-
extern "C" {
7-
#endif
8-
95
#include "cpython/initconfig.h"
106

117
PyAPI_FUNC(int) _PyInterpreterState_RequiresIDRef(PyInterpreterState *);
@@ -257,7 +253,3 @@ typedef int (*crossinterpdatafunc)(PyObject *, struct _xid *);
257253

258254
PyAPI_FUNC(int) _PyCrossInterpreterData_RegisterClass(PyTypeObject *, crossinterpdatafunc);
259255
PyAPI_FUNC(crossinterpdatafunc) _PyCrossInterpreterData_Lookup(PyObject *);
260-
261-
#ifdef __cplusplus
262-
}
263-
#endif

Include/cpython/sysmodule.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
# error "this header file must not be included directly"
33
#endif
44

5-
#ifdef __cplusplus
6-
extern "C" {
7-
#endif
8-
95
PyAPI_FUNC(PyObject *) _PySys_GetObjectId(_Py_Identifier *key);
106
PyAPI_FUNC(int) _PySys_SetObjectId(_Py_Identifier *key, PyObject *);
117

@@ -18,7 +14,3 @@ PyAPI_FUNC(int) PySys_Audit(
1814
const char *argFormat,
1915
...);
2016
PyAPI_FUNC(int) PySys_AddAuditHook(Py_AuditHookFunction, void*);
21-
22-
#ifdef __cplusplus
23-
}
24-
#endif

Include/cpython/traceback.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
# error "this header file must not be included directly"
33
#endif
44

5-
#ifdef __cplusplus
6-
extern "C" {
7-
#endif
8-
95
typedef struct _traceback {
106
PyObject_HEAD
117
struct _traceback *tb_next;
@@ -16,7 +12,3 @@ typedef struct _traceback {
1612

1713
PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, PyObject *, int, int);
1814
PyAPI_FUNC(void) _PyTraceback_Add(const char *, const char *, int);
19-
20-
#ifdef __cplusplus
21-
}
22-
#endif

Include/cpython/tupleobject.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
# error "this header file must not be included directly"
33
#endif
44

5-
#ifdef __cplusplus
6-
extern "C" {
7-
#endif
8-
95
typedef struct {
106
PyObject_VAR_HEAD
117
/* ob_item contains space for 'ob_size' elements.
@@ -30,7 +26,3 @@ PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *);
3026
#define PyTuple_SET_ITEM(op, i, v) (_PyTuple_CAST(op)->ob_item[i] = v)
3127

3228
PyAPI_FUNC(void) _PyTuple_DebugMallocStats(FILE *out);
33-
34-
#ifdef __cplusplus
35-
}
36-
#endif

Include/cpython/unicodeobject.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
# error "this header file must not be included directly"
33
#endif
44

5-
#ifdef __cplusplus
6-
extern "C" {
7-
#endif
8-
95
/* Py_UNICODE was the native Unicode storage format (code unit) used by
106
Python and represents a single Unicode element in the Unicode type.
117
With PEP 393, Py_UNICODE is deprecated and replaced with a
@@ -1221,7 +1217,3 @@ PyAPI_FUNC(PyObject*) _PyUnicode_FromId(_Py_Identifier*);
12211217
PyAPI_FUNC(int) _PyUnicode_EQ(PyObject *, PyObject *);
12221218

12231219
PyAPI_FUNC(Py_ssize_t) _PyUnicode_ScanIdentifier(PyObject *);
1224-
1225-
#ifdef __cplusplus
1226-
}
1227-
#endif
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove superfluous "extern C" declarations from ``Include/cpython/*.h``.

0 commit comments

Comments
 (0)