gh-116869: Make C API compatible with ISO C90 (#116950)

Make the C API compatible with -Werror=declaration-after-statement
compiler flag again.
This commit is contained in:
Victor Stinner 2024-03-18 20:16:58 +01:00 committed by GitHub
parent 590a26010d
commit a9c304cf02
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 3 deletions

View File

@ -129,9 +129,10 @@ _PyLong_IsCompact(const PyLongObject* op) {
static inline Py_ssize_t
_PyLong_CompactValue(const PyLongObject *op)
{
Py_ssize_t sign;
assert(PyType_HasFeature((op)->ob_base.ob_type, Py_TPFLAGS_LONG_SUBCLASS));
assert(PyUnstable_Long_IsCompact(op));
Py_ssize_t sign = 1 - (op->long_value.lv_tag & _PyLong_SIGN_MASK);
sign = 1 - (op->long_value.lv_tag & _PyLong_SIGN_MASK);
return sign * (Py_ssize_t)op->long_value.ob_digit[0];
}

View File

@ -343,8 +343,7 @@ PyAPI_DATA(PyTypeObject) PyBool_Type;
static inline Py_ssize_t Py_SIZE(PyObject *ob) {
assert(ob->ob_type != &PyLong_Type);
assert(ob->ob_type != &PyBool_Type);
PyVarObject *var_ob = _PyVarObject_CAST(ob);
return var_ob->ob_size;
return _PyVarObject_CAST(ob)->ob_size;
}
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
# define Py_SIZE(ob) Py_SIZE(_PyObject_CAST(ob))

View File

@ -0,0 +1,2 @@
Make the C API compatible with ``-Werror=declaration-after-statement``
compiler flag again. Patch by Victor Stinner.