From b4d5a5cca29426a282e8f1e64b2271fdd1f0a23e Mon Sep 17 00:00:00 2001 From: Skip Montanaro Date: Mon, 1 Jun 2020 13:35:56 -0500 Subject: bpo-39583: Remove superfluous "extern C" bits from Include/cpython/*.h (GH-18413) --- Include/cpython/abstract.h | 10 +--------- Include/cpython/ceval.h | 8 -------- Include/cpython/dictobject.h | 8 -------- Include/cpython/fileobject.h | 8 -------- Include/cpython/frameobject.h | 8 -------- Include/cpython/import.h | 8 -------- Include/cpython/initconfig.h | 6 ------ Include/cpython/interpreteridobject.h | 8 -------- Include/cpython/listobject.h | 8 -------- Include/cpython/object.h | 8 -------- Include/cpython/objimpl.h | 8 -------- Include/cpython/pyerrors.h | 8 -------- Include/cpython/pylifecycle.h | 8 -------- Include/cpython/pymem.h | 8 -------- Include/cpython/pystate.h | 8 -------- Include/cpython/sysmodule.h | 8 -------- Include/cpython/traceback.h | 8 -------- Include/cpython/tupleobject.h | 8 -------- Include/cpython/unicodeobject.h | 8 -------- .../NEWS.d/next/C API/2020-02-08-08-01-35.bpo-39583.qURKSl.rst | 1 + 20 files changed, 2 insertions(+), 151 deletions(-) create mode 100644 Misc/NEWS.d/next/C API/2020-02-08-08-01-35.bpo-39583.qURKSl.rst diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h index aa72f99..b5b6e48 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 e1922a6..0633892 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 e33a0d1..ffe0e97 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 57eac13..4f2408c 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 36a51ba..c76fbe0 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 c1b4712..3b20a74 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 df93a55..e9c2e6b 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 67ec587..5076584 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 74fe330..b1af5f6 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 444f832..304cfbf 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 b835936..ca4009b 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 dd3c2ca..3f347dc 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 eb523b8..f38ec5a 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 79f063b..61d7195 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 f292da1..42a7fc1 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 1802b5b..fc4c899 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 837470c..aac5b42 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 1565f2a..51dcd42 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 4fd674f..3b49ce7 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 0000000..1c9f44f --- /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``. -- cgit v0.12