diff options
Diffstat (limited to 'Include/cpython')
-rw-r--r-- | Include/cpython/abstract.h | 2 | ||||
-rw-r--r-- | Include/cpython/classobject.h | 6 | ||||
-rw-r--r-- | Include/cpython/code.h | 3 | ||||
-rw-r--r-- | Include/cpython/listobject.h | 4 | ||||
-rw-r--r-- | Include/cpython/modsupport.h | 4 | ||||
-rw-r--r-- | Include/cpython/object.h | 12 | ||||
-rw-r--r-- | Include/cpython/odictobject.h | 8 | ||||
-rw-r--r-- | Include/cpython/pyerrors.h | 2 | ||||
-rw-r--r-- | Include/cpython/pythonrun.h | 28 | ||||
-rw-r--r-- | Include/cpython/tupleobject.h | 4 | ||||
-rw-r--r-- | Include/cpython/warnings.h | 2 |
11 files changed, 38 insertions, 37 deletions
diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h index d276669..7038918 100644 --- a/Include/cpython/abstract.h +++ b/Include/cpython/abstract.h @@ -176,7 +176,7 @@ PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t); /* Assume tp_as_sequence and sq_item exist and that 'i' does not need to be corrected for a negative index. */ #define PySequence_ITEM(o, i)\ - ( Py_TYPE(o)->tp_as_sequence->sq_item(o, i) ) + ( Py_TYPE(o)->tp_as_sequence->sq_item((o), (i)) ) #define PY_ITERSEARCH_COUNT 1 #define PY_ITERSEARCH_INDEX 2 diff --git a/Include/cpython/classobject.h b/Include/cpython/classobject.h index d748e2c..0510419 100644 --- a/Include/cpython/classobject.h +++ b/Include/cpython/classobject.h @@ -29,9 +29,9 @@ PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *); /* Macros for direct access to these values. Type checks are *not* done, so use with care. */ #define PyMethod_GET_FUNCTION(meth) \ - (((PyMethodObject *)meth) -> im_func) + (((PyMethodObject *)(meth)) -> im_func) #define PyMethod_GET_SELF(meth) \ - (((PyMethodObject *)meth) -> im_self) + (((PyMethodObject *)(meth)) -> im_self) typedef struct { PyObject_HEAD @@ -48,7 +48,7 @@ PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *); /* Macros for direct access to these values. Type checks are *not* done, so use with care. */ #define PyInstanceMethod_GET_FUNCTION(meth) \ - (((PyInstanceMethodObject *)meth) -> func) + (((PyInstanceMethodObject *)(meth)) -> func) #ifdef __cplusplus } diff --git a/Include/cpython/code.h b/Include/cpython/code.h index 238bf94..ebc0df9 100644 --- a/Include/cpython/code.h +++ b/Include/cpython/code.h @@ -29,7 +29,8 @@ typedef uint16_t _Py_CODEUNIT; #endif // Use "unsigned char" instead of "uint8_t" here to avoid illegal aliasing: -#define _Py_SET_OPCODE(word, opcode) (((unsigned char *)&(word))[0] = (opcode)) +#define _Py_SET_OPCODE(word, opcode) \ + do { ((unsigned char *)&(word))[0] = (opcode); } while (0) // To avoid repeating ourselves in deepfreeze.py, all PyCodeObject members are // defined in this macro: diff --git a/Include/cpython/listobject.h b/Include/cpython/listobject.h index b094560..8fa8212 100644 --- a/Include/cpython/listobject.h +++ b/Include/cpython/listobject.h @@ -36,7 +36,7 @@ static inline Py_ssize_t PyList_GET_SIZE(PyObject *op) { } #define PyList_GET_SIZE(op) PyList_GET_SIZE(_PyObject_CAST(op)) -#define PyList_GET_ITEM(op, index) (_PyList_CAST(op)->ob_item[index]) +#define PyList_GET_ITEM(op, index) (_PyList_CAST(op)->ob_item[(index)]) static inline void PyList_SET_ITEM(PyObject *op, Py_ssize_t index, PyObject *value) { @@ -44,4 +44,4 @@ PyList_SET_ITEM(PyObject *op, Py_ssize_t index, PyObject *value) { list->ob_item[index] = value; } #define PyList_SET_ITEM(op, index, value) \ - PyList_SET_ITEM(_PyObject_CAST(op), index, _PyObject_CAST(value)) + PyList_SET_ITEM(_PyObject_CAST(op), (index), _PyObject_CAST(value)) diff --git a/Include/cpython/modsupport.h b/Include/cpython/modsupport.h index 74ef999..591dcb1 100644 --- a/Include/cpython/modsupport.h +++ b/Include/cpython/modsupport.h @@ -34,7 +34,7 @@ PyAPI_FUNC(int) _PyArg_NoPositional(const char *funcname, PyObject *args); #define _PyArg_NoPositional(funcname, args) \ ((args) == NULL || _PyArg_NoPositional((funcname), (args))) -#define _Py_ANY_VARARGS(n) (n == PY_SSIZE_T_MAX) +#define _Py_ANY_VARARGS(n) ((n) == PY_SSIZE_T_MAX) PyAPI_FUNC(void) _PyArg_BadArgument(const char *, const char *, const char *, PyObject *); PyAPI_FUNC(int) _PyArg_CheckPositional(const char *, Py_ssize_t, @@ -100,7 +100,7 @@ PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywordsWithVararg( #define _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, parser, minpos, maxpos, minkw, buf) \ (((minkw) == 0 && (kwargs) == NULL && (kwnames) == NULL && \ - (minpos) <= (nargs) && (nargs) <= (maxpos) && args != NULL) ? (args) : \ + (minpos) <= (nargs) && (nargs) <= (maxpos) && (args) != NULL) ? (args) : \ _PyArg_UnpackKeywords((args), (nargs), (kwargs), (kwnames), (parser), \ (minpos), (maxpos), (minkw), (buf))) diff --git a/Include/cpython/object.h b/Include/cpython/object.h index b018dab..614d6c1 100644 --- a/Include/cpython/object.h +++ b/Include/cpython/object.h @@ -45,7 +45,7 @@ typedef struct _Py_Identifier { // For now we are keeping _Py_IDENTIFIER for continued use // in non-builtin extensions (and naughty PyPI modules). -#define _Py_static_string_init(value) { .string = value, .index = -1 } +#define _Py_static_string_init(value) { .string = (value), .index = -1 } #define _Py_static_string(varname, value) static _Py_Identifier varname = _Py_static_string_init(value) #define _Py_IDENTIFIER(varname) _Py_static_string(PyId_##varname, #varname) @@ -385,9 +385,9 @@ _PyObject_DebugTypeStats(FILE *out); #endif #define _PyObject_ASSERT_WITH_MSG(obj, expr, msg) \ - _PyObject_ASSERT_FROM(obj, expr, msg, __FILE__, __LINE__, __func__) + _PyObject_ASSERT_FROM((obj), expr, (msg), __FILE__, __LINE__, __func__) #define _PyObject_ASSERT(obj, expr) \ - _PyObject_ASSERT_WITH_MSG(obj, expr, NULL) + _PyObject_ASSERT_WITH_MSG((obj), expr, NULL) #define _PyObject_ASSERT_FAILED_MSG(obj, msg) \ _PyObject_AssertFailed((obj), NULL, (msg), __FILE__, __LINE__, __func__) @@ -493,8 +493,8 @@ PyAPI_FUNC(int) _PyTrash_cond(PyObject *op, destructor dealloc); } while (0); #define Py_TRASHCAN_BEGIN(op, dealloc) \ - Py_TRASHCAN_BEGIN_CONDITION(op, \ - _PyTrash_cond(_PyObject_CAST(op), (destructor)dealloc)) + Py_TRASHCAN_BEGIN_CONDITION((op), \ + _PyTrash_cond(_PyObject_CAST(op), (destructor)(dealloc))) /* The following two macros, Py_TRASHCAN_SAFE_BEGIN and * Py_TRASHCAN_SAFE_END, are deprecated since version 3.11 and @@ -505,7 +505,7 @@ Py_DEPRECATED(3.11) typedef int UsingDeprecatedTrashcanMacro; #define Py_TRASHCAN_SAFE_BEGIN(op) \ do { \ UsingDeprecatedTrashcanMacro cond=1; \ - Py_TRASHCAN_BEGIN_CONDITION(op, cond); + Py_TRASHCAN_BEGIN_CONDITION((op), cond); #define Py_TRASHCAN_SAFE_END(op) \ Py_TRASHCAN_END; \ } while(0); diff --git a/Include/cpython/odictobject.h b/Include/cpython/odictobject.h index ce54d48..3822d55 100644 --- a/Include/cpython/odictobject.h +++ b/Include/cpython/odictobject.h @@ -27,13 +27,13 @@ PyAPI_FUNC(int) PyODict_SetItem(PyObject *od, PyObject *key, PyObject *item); PyAPI_FUNC(int) PyODict_DelItem(PyObject *od, PyObject *key); /* wrappers around PyDict* functions */ -#define PyODict_GetItem(od, key) PyDict_GetItem(_PyObject_CAST(od), key) +#define PyODict_GetItem(od, key) PyDict_GetItem(_PyObject_CAST(od), (key)) #define PyODict_GetItemWithError(od, key) \ - PyDict_GetItemWithError(_PyObject_CAST(od), key) -#define PyODict_Contains(od, key) PyDict_Contains(_PyObject_CAST(od), key) + PyDict_GetItemWithError(_PyObject_CAST(od), (key)) +#define PyODict_Contains(od, key) PyDict_Contains(_PyObject_CAST(od), (key)) #define PyODict_Size(od) PyDict_Size(_PyObject_CAST(od)) #define PyODict_GetItemString(od, key) \ - PyDict_GetItemString(_PyObject_CAST(od), key) + PyDict_GetItemString(_PyObject_CAST(od), (key)) #endif diff --git a/Include/cpython/pyerrors.h b/Include/cpython/pyerrors.h index 47d80e3..f33d3ca 100644 --- a/Include/cpython/pyerrors.h +++ b/Include/cpython/pyerrors.h @@ -176,4 +176,4 @@ PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalErrorFormat( const char *format, ...); -#define Py_FatalError(message) _Py_FatalErrorFunc(__func__, message) +#define Py_FatalError(message) _Py_FatalErrorFunc(__func__, (message)) diff --git a/Include/cpython/pythonrun.h b/Include/cpython/pythonrun.h index 2e72d08..fb61765 100644 --- a/Include/cpython/pythonrun.h +++ b/Include/cpython/pythonrun.h @@ -66,8 +66,8 @@ PyAPI_FUNC(PyObject *) Py_CompileStringObject( PyCompilerFlags *flags, int optimize); -#define Py_CompileString(str, p, s) Py_CompileStringExFlags(str, p, s, NULL, -1) -#define Py_CompileStringFlags(str, p, s, f) Py_CompileStringExFlags(str, p, s, f, -1) +#define Py_CompileString(str, p, s) Py_CompileStringExFlags((str), (p), (s), NULL, -1) +#define Py_CompileStringFlags(str, p, s, f) Py_CompileStringExFlags((str), (p), (s), (f), -1) PyAPI_FUNC(const char *) _Py_SourceAsString( @@ -96,23 +96,23 @@ PyAPI_FUNC(PyObject *) PyRun_FileEx(FILE *fp, const char *p, int s, PyObject *g, PyAPI_FUNC(PyObject *) PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, PyCompilerFlags *flags); /* Use macros for a bunch of old variants */ -#define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL) -#define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL) +#define PyRun_String(str, s, g, l) PyRun_StringFlags((str), (s), (g), (l), NULL) +#define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags((fp), (name), 0, NULL) #define PyRun_AnyFileEx(fp, name, closeit) \ - PyRun_AnyFileExFlags(fp, name, closeit, NULL) + PyRun_AnyFileExFlags((fp), (name), (closeit), NULL) #define PyRun_AnyFileFlags(fp, name, flags) \ - PyRun_AnyFileExFlags(fp, name, 0, flags) -#define PyRun_SimpleString(s) PyRun_SimpleStringFlags(s, NULL) -#define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags(f, p, 0, NULL) -#define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags(f, p, c, NULL) -#define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags(f, p, NULL) -#define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags(f, p, NULL) + PyRun_AnyFileExFlags((fp), (name), 0, (flags)) +#define PyRun_SimpleString(s) PyRun_SimpleStringFlags((s), NULL) +#define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags((f), (p), 0, NULL) +#define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags((f), (p), (c), NULL) +#define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags((f), (p), NULL) +#define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags((f), (p), NULL) #define PyRun_File(fp, p, s, g, l) \ - PyRun_FileExFlags(fp, p, s, g, l, 0, NULL) + PyRun_FileExFlags((fp), (p), (s), (g), (l), 0, NULL) #define PyRun_FileEx(fp, p, s, g, l, c) \ - PyRun_FileExFlags(fp, p, s, g, l, c, NULL) + PyRun_FileExFlags((fp), (p), (s), (g), (l), (c), NULL) #define PyRun_FileFlags(fp, p, s, g, l, flags) \ - PyRun_FileExFlags(fp, p, s, g, l, 0, flags) + PyRun_FileExFlags((fp), (p), (s), (g), (l), 0, (flags)) /* Stuff with no proper home (yet) */ diff --git a/Include/cpython/tupleobject.h b/Include/cpython/tupleobject.h index 30303fa..f6a1f07 100644 --- a/Include/cpython/tupleobject.h +++ b/Include/cpython/tupleobject.h @@ -25,7 +25,7 @@ static inline Py_ssize_t PyTuple_GET_SIZE(PyObject *op) { } #define PyTuple_GET_SIZE(op) PyTuple_GET_SIZE(_PyObject_CAST(op)) -#define PyTuple_GET_ITEM(op, index) (_PyTuple_CAST(op)->ob_item[index]) +#define PyTuple_GET_ITEM(op, index) (_PyTuple_CAST(op)->ob_item[(index)]) /* Function *only* to be used to fill in brand new tuples */ static inline void @@ -34,6 +34,6 @@ PyTuple_SET_ITEM(PyObject *op, Py_ssize_t index, PyObject *value) { tuple->ob_item[index] = value; } #define PyTuple_SET_ITEM(op, index, value) \ - PyTuple_SET_ITEM(_PyObject_CAST(op), index, _PyObject_CAST(value)) + PyTuple_SET_ITEM(_PyObject_CAST(op), (index), _PyObject_CAST(value)) PyAPI_FUNC(void) _PyTuple_DebugMallocStats(FILE *out); diff --git a/Include/cpython/warnings.h b/Include/cpython/warnings.h index 2ef8e3c..4e3eb88 100644 --- a/Include/cpython/warnings.h +++ b/Include/cpython/warnings.h @@ -17,4 +17,4 @@ PyAPI_FUNC(int) PyErr_WarnExplicitFormat( const char *format, ...); // DEPRECATED: Use PyErr_WarnEx() instead. -#define PyErr_Warn(category, msg) PyErr_WarnEx(category, msg, 1) +#define PyErr_Warn(category, msg) PyErr_WarnEx((category), (msg), 1) |