[Python-checkins] bpo-39583: Remove superfluous "extern C" bits from Include/cpython/*.h (GH-18413)

Skip Montanaro webhook-mailer at python.org
Mon Jun 1 14:36:05 EDT 2020


https://github.com/python/cpython/commit/b4d5a5cca29426a282e8f1e64b2271fdd1f0a23e
commit: b4d5a5cca29426a282e8f1e64b2271fdd1f0a23e
branch: master
author: Skip Montanaro <skip.montanaro at gmail.com>
committer: GitHub <noreply at github.com>
date: 2020-06-01T20:35:56+02:00
summary:

bpo-39583: Remove superfluous "extern C" bits from Include/cpython/*.h (GH-18413)

files:
A Misc/NEWS.d/next/C API/2020-02-08-08-01-35.bpo-39583.qURKSl.rst
M Include/cpython/abstract.h
M Include/cpython/ceval.h
M Include/cpython/dictobject.h
M Include/cpython/fileobject.h
M Include/cpython/frameobject.h
M Include/cpython/import.h
M Include/cpython/initconfig.h
M Include/cpython/interpreteridobject.h
M Include/cpython/listobject.h
M Include/cpython/object.h
M Include/cpython/objimpl.h
M Include/cpython/pyerrors.h
M Include/cpython/pylifecycle.h
M Include/cpython/pymem.h
M Include/cpython/pystate.h
M Include/cpython/sysmodule.h
M Include/cpython/traceback.h
M Include/cpython/tupleobject.h
M Include/cpython/unicodeobject.h

diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h
index aa72f998b701c..b5b6e4819788c 100644
--- a/Include/cpython/abstract.h
+++ b/Include/cpython/abstract.h
@@ -2,10 +2,6 @@
 #  error "this header file must not be included directly"
 #endif
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 /* === Object Protocol ================================================== */
 
 #ifdef PY_SSIZE_T_CLEAN
@@ -380,8 +376,4 @@ PyAPI_FUNC(void) _Py_add_one_to_index_C(int nd, Py_ssize_t *index,
 PyAPI_FUNC(int) _Py_convert_optional_to_ssize_t(PyObject *, void *);
 
 /* Same as PyNumber_Index but can return an instance of a subclass of int. */
-PyAPI_FUNC(PyObject *) _PyNumber_Index(PyObject *o);
-
-#ifdef __cplusplus
-}
-#endif
+PyAPI_FUNC(PyObject *) _PyNumber_Index(PyObject *o);
\ No newline at end of file
diff --git a/Include/cpython/ceval.h b/Include/cpython/ceval.h
index e1922a677bd38..06338928f6738 100644
--- a/Include/cpython/ceval.h
+++ b/Include/cpython/ceval.h
@@ -2,10 +2,6 @@
 #  error "this header file must not be included directly"
 #endif
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
 PyAPI_DATA(int) _PyEval_SetProfile(PyThreadState *tstate, Py_tracefunc func, PyObject *arg);
 PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
@@ -32,7 +28,3 @@ PyAPI_FUNC(Py_ssize_t) _PyEval_RequestCodeExtraIndex(freefunc);
 
 PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *);
 PyAPI_FUNC(int) _PyEval_SliceIndexNotNone(PyObject *, Py_ssize_t *);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/Include/cpython/dictobject.h b/Include/cpython/dictobject.h
index e33a0d156fead..ffe0e97fb35f3 100644
--- a/Include/cpython/dictobject.h
+++ b/Include/cpython/dictobject.h
@@ -2,10 +2,6 @@
 #  error "this header file must not be included directly"
 #endif
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 typedef struct _dictkeysobject PyDictKeysObject;
 
 /* The ma_values pointer is NULL for a combined table
@@ -86,7 +82,3 @@ typedef struct {
 
 PyAPI_FUNC(PyObject *) _PyDictView_New(PyObject *, PyTypeObject *);
 PyAPI_FUNC(PyObject *) _PyDictView_Intersect(PyObject* self, PyObject *other);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/Include/cpython/fileobject.h b/Include/cpython/fileobject.h
index 57eac13c064c2..4f2408c7e8760 100644
--- a/Include/cpython/fileobject.h
+++ b/Include/cpython/fileobject.h
@@ -2,10 +2,6 @@
 #  error "this header file must not be included directly"
 #endif
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 PyAPI_FUNC(char *) Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *);
 
 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000
@@ -26,7 +22,3 @@ typedef PyObject * (*Py_OpenCodeHookFunction)(PyObject *, void *);
 PyAPI_FUNC(PyObject *) PyFile_OpenCode(const char *utf8path);
 PyAPI_FUNC(PyObject *) PyFile_OpenCodeObject(PyObject *path);
 PyAPI_FUNC(int) PyFile_SetOpenCodeHook(Py_OpenCodeHookFunction hook, void *userData);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/Include/cpython/frameobject.h b/Include/cpython/frameobject.h
index 36a51baae8784..c76fbe0616cb2 100644
--- a/Include/cpython/frameobject.h
+++ b/Include/cpython/frameobject.h
@@ -4,10 +4,6 @@
 #  error "this header file must not be included directly"
 #endif
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 typedef struct {
     int b_type;                 /* what kind of block this is */
     int b_handler;              /* where to jump to find handler */
@@ -78,7 +74,3 @@ PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *);
 PyAPI_FUNC(void) _PyFrame_DebugMallocStats(FILE *out);
 
 PyAPI_FUNC(PyFrameObject *) PyFrame_GetBack(PyFrameObject *frame);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/Include/cpython/import.h b/Include/cpython/import.h
index c1b47121f1246..3b20a74c855db 100644
--- a/Include/cpython/import.h
+++ b/Include/cpython/import.h
@@ -2,10 +2,6 @@
 #  error "this header file must not be included directly"
 #endif
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 PyMODINIT_FUNC PyInit__imp(void);
 
 PyAPI_FUNC(int) _PyImport_IsInitialized(PyInterpreterState *);
@@ -44,7 +40,3 @@ struct _frozen {
    collection of frozen modules: */
 
 PyAPI_DATA(const struct _frozen *) PyImport_FrozenModules;
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/Include/cpython/initconfig.h b/Include/cpython/initconfig.h
index df93a5539d48b..e9c2e6bec3861 100644
--- a/Include/cpython/initconfig.h
+++ b/Include/cpython/initconfig.h
@@ -1,9 +1,6 @@
 #ifndef Py_PYCORECONFIG_H
 #define Py_PYCORECONFIG_H
 #ifndef Py_LIMITED_API
-#ifdef __cplusplus
-extern "C" {
-#endif
 
 /* --- PyStatus ----------------------------------------------- */
 
@@ -438,8 +435,5 @@ PyAPI_FUNC(PyStatus) PyConfig_SetWideStringList(PyConfig *config,
     PyWideStringList *list,
     Py_ssize_t length, wchar_t **items);
 
-#ifdef __cplusplus
-}
-#endif
 #endif /* !Py_LIMITED_API */
 #endif /* !Py_PYCORECONFIG_H */
diff --git a/Include/cpython/interpreteridobject.h b/Include/cpython/interpreteridobject.h
index 67ec5873542d8..5076584209b90 100644
--- a/Include/cpython/interpreteridobject.h
+++ b/Include/cpython/interpreteridobject.h
@@ -2,10 +2,6 @@
 #  error "this header file must not be included directly"
 #endif
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 /* Interpreter ID Object */
 
 PyAPI_DATA(PyTypeObject) _PyInterpreterID_Type;
@@ -13,7 +9,3 @@ PyAPI_DATA(PyTypeObject) _PyInterpreterID_Type;
 PyAPI_FUNC(PyObject *) _PyInterpreterID_New(int64_t);
 PyAPI_FUNC(PyObject *) _PyInterpreterState_GetIDObject(PyInterpreterState *);
 PyAPI_FUNC(PyInterpreterState *) _PyInterpreterID_LookUp(PyObject *);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/Include/cpython/listobject.h b/Include/cpython/listobject.h
index 74fe3301a7ab7..b1af5f6764427 100644
--- a/Include/cpython/listobject.h
+++ b/Include/cpython/listobject.h
@@ -2,10 +2,6 @@
 #  error "this header file must not be included directly"
 #endif
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 typedef struct {
     PyObject_VAR_HEAD
     /* Vector of pointers to list elements.  list[0] is ob_item[0], etc. */
@@ -37,7 +33,3 @@ PyAPI_FUNC(void) _PyList_DebugMallocStats(FILE *out);
 #define PyList_SET_ITEM(op, i, v) (_PyList_CAST(op)->ob_item[i] = (v))
 #define PyList_GET_SIZE(op)    Py_SIZE(_PyList_CAST(op))
 #define _PyList_ITEMS(op)      (_PyList_CAST(op)->ob_item)
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/Include/cpython/object.h b/Include/cpython/object.h
index 444f832f5bd8d..304cfbfc37dff 100644
--- a/Include/cpython/object.h
+++ b/Include/cpython/object.h
@@ -2,10 +2,6 @@
 #  error "this header file must not be included directly"
 #endif
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 PyAPI_FUNC(void) _Py_NewReference(PyObject *op);
 
 #ifdef Py_TRACE_REFS
@@ -548,7 +544,3 @@ PyAPI_FUNC(void) _PyTrash_end(struct _ts *tstate);
  * unconditionally */
 #define Py_TRASHCAN_SAFE_BEGIN(op) Py_TRASHCAN_BEGIN_CONDITION(op, 1)
 #define Py_TRASHCAN_SAFE_END(op) Py_TRASHCAN_END
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/Include/cpython/objimpl.h b/Include/cpython/objimpl.h
index b835936db7011..ca4009bcdb4c1 100644
--- a/Include/cpython/objimpl.h
+++ b/Include/cpython/objimpl.h
@@ -2,10 +2,6 @@
 #  error "this header file must not be included directly"
 #endif
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #define _PyObject_SIZE(typeobj) ( (typeobj)->tp_basicsize )
 
 /* _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);
 #define PyType_SUPPORTS_WEAKREFS(t) ((t)->tp_weaklistoffset > 0)
 
 PyAPI_FUNC(PyObject **) PyObject_GET_WEAKREFS_LISTPTR(PyObject *op);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/Include/cpython/pyerrors.h b/Include/cpython/pyerrors.h
index dd3c2caa0cc04..3f347dc2e2d62 100644
--- a/Include/cpython/pyerrors.h
+++ b/Include/cpython/pyerrors.h
@@ -2,10 +2,6 @@
 #  error "this header file must not be included directly"
 #endif
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 /* Error objects */
 
 /* PyException_HEAD defines the initial segment of every exception class. */
@@ -188,7 +184,3 @@ PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalErrorFormat(
     ...);
 
 #define Py_FatalError(message) _Py_FatalErrorFunc(__func__, message)
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/Include/cpython/pylifecycle.h b/Include/cpython/pylifecycle.h
index eb523b82e182d..f38ec5a4ae399 100644
--- a/Include/cpython/pylifecycle.h
+++ b/Include/cpython/pylifecycle.h
@@ -2,10 +2,6 @@
 #  error "this header file must not be included directly"
 #endif
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 /* Only used by applications that embed the interpreter and need to
  * override the standard encoding determination mechanism
  */
@@ -66,7 +62,3 @@ PyAPI_FUNC(int) _Py_LegacyLocaleDetected(int warn);
 PyAPI_FUNC(char *) _Py_SetLocaleFromEnv(int category);
 
 PyAPI_FUNC(PyThreadState *) _Py_NewInterpreter(int isolated_subinterpreter);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/Include/cpython/pymem.h b/Include/cpython/pymem.h
index 79f063b121753..61d719584584e 100644
--- a/Include/cpython/pymem.h
+++ b/Include/cpython/pymem.h
@@ -2,10 +2,6 @@
 #  error "this header file must not be included directly"
 #endif
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 PyAPI_FUNC(void *) PyMem_RawMalloc(size_t size);
 PyAPI_FUNC(void *) PyMem_RawCalloc(size_t nelem, size_t elsize);
 PyAPI_FUNC(void *) PyMem_RawRealloc(void *ptr, size_t new_size);
@@ -102,7 +98,3 @@ PyAPI_FUNC(void) PyMem_SetAllocator(PyMemAllocatorDomain domain,
 
    The function does nothing if Python is not compiled is debug mode. */
 PyAPI_FUNC(void) PyMem_SetupDebugHooks(void);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h
index f292da1d3c6c5..42a7fc163064d 100644
--- a/Include/cpython/pystate.h
+++ b/Include/cpython/pystate.h
@@ -2,10 +2,6 @@
 #  error "this header file must not be included directly"
 #endif
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include "cpython/initconfig.h"
 
 PyAPI_FUNC(int) _PyInterpreterState_RequiresIDRef(PyInterpreterState *);
@@ -257,7 +253,3 @@ typedef int (*crossinterpdatafunc)(PyObject *, struct _xid *);
 
 PyAPI_FUNC(int) _PyCrossInterpreterData_RegisterClass(PyTypeObject *, crossinterpdatafunc);
 PyAPI_FUNC(crossinterpdatafunc) _PyCrossInterpreterData_Lookup(PyObject *);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/Include/cpython/sysmodule.h b/Include/cpython/sysmodule.h
index 1802b5b300018..fc4c899b3fe3d 100644
--- a/Include/cpython/sysmodule.h
+++ b/Include/cpython/sysmodule.h
@@ -2,10 +2,6 @@
 #  error "this header file must not be included directly"
 #endif
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 PyAPI_FUNC(PyObject *) _PySys_GetObjectId(_Py_Identifier *key);
 PyAPI_FUNC(int) _PySys_SetObjectId(_Py_Identifier *key, PyObject *);
 
@@ -18,7 +14,3 @@ PyAPI_FUNC(int) PySys_Audit(
     const char *argFormat,
     ...);
 PyAPI_FUNC(int) PySys_AddAuditHook(Py_AuditHookFunction, void*);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/Include/cpython/traceback.h b/Include/cpython/traceback.h
index 837470c3ba2bc..aac5b42c344d3 100644
--- a/Include/cpython/traceback.h
+++ b/Include/cpython/traceback.h
@@ -2,10 +2,6 @@
 #  error "this header file must not be included directly"
 #endif
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 typedef struct _traceback {
     PyObject_HEAD
     struct _traceback *tb_next;
@@ -16,7 +12,3 @@ typedef struct _traceback {
 
 PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, PyObject *, int, int);
 PyAPI_FUNC(void) _PyTraceback_Add(const char *, const char *, int);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/Include/cpython/tupleobject.h b/Include/cpython/tupleobject.h
index 1565f2a5c3d98..51dcd4237be18 100644
--- a/Include/cpython/tupleobject.h
+++ b/Include/cpython/tupleobject.h
@@ -2,10 +2,6 @@
 #  error "this header file must not be included directly"
 #endif
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 typedef struct {
     PyObject_VAR_HEAD
     /* ob_item contains space for 'ob_size' elements.
@@ -30,7 +26,3 @@ PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *);
 #define PyTuple_SET_ITEM(op, i, v) (_PyTuple_CAST(op)->ob_item[i] = v)
 
 PyAPI_FUNC(void) _PyTuple_DebugMallocStats(FILE *out);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/Include/cpython/unicodeobject.h b/Include/cpython/unicodeobject.h
index 4fd674ffea36e..3b49ce7759037 100644
--- a/Include/cpython/unicodeobject.h
+++ b/Include/cpython/unicodeobject.h
@@ -2,10 +2,6 @@
 #  error "this header file must not be included directly"
 #endif
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 /* Py_UNICODE was the native Unicode storage format (code unit) used by
    Python and represents a single Unicode element in the Unicode type.
    With PEP 393, Py_UNICODE is deprecated and replaced with a
@@ -1221,7 +1217,3 @@ PyAPI_FUNC(PyObject*) _PyUnicode_FromId(_Py_Identifier*);
 PyAPI_FUNC(int) _PyUnicode_EQ(PyObject *, PyObject *);
 
 PyAPI_FUNC(Py_ssize_t) _PyUnicode_ScanIdentifier(PyObject *);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/Misc/NEWS.d/next/C API/2020-02-08-08-01-35.bpo-39583.qURKSl.rst b/Misc/NEWS.d/next/C API/2020-02-08-08-01-35.bpo-39583.qURKSl.rst
new file mode 100644
index 0000000000000..1c9f44f7443c1
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2020-02-08-08-01-35.bpo-39583.qURKSl.rst	
@@ -0,0 +1 @@
+Remove superfluous "extern C" declarations from ``Include/cpython/*.h``.



More information about the Python-checkins mailing list