Skip to content

Commit a9c304c

Browse files
authored
gh-116869: Make C API compatible with ISO C90 (#116950)
Make the C API compatible with -Werror=declaration-after-statement compiler flag again.
1 parent 590a260 commit a9c304c

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

Include/cpython/longintrepr.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,10 @@ _PyLong_IsCompact(const PyLongObject* op) {
129129
static inline Py_ssize_t
130130
_PyLong_CompactValue(const PyLongObject *op)
131131
{
132+
Py_ssize_t sign;
132133
assert(PyType_HasFeature((op)->ob_base.ob_type, Py_TPFLAGS_LONG_SUBCLASS));
133134
assert(PyUnstable_Long_IsCompact(op));
134-
Py_ssize_t sign = 1 - (op->long_value.lv_tag & _PyLong_SIGN_MASK);
135+
sign = 1 - (op->long_value.lv_tag & _PyLong_SIGN_MASK);
135136
return sign * (Py_ssize_t)op->long_value.ob_digit[0];
136137
}
137138

Include/object.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,7 @@ PyAPI_DATA(PyTypeObject) PyBool_Type;
343343
static inline Py_ssize_t Py_SIZE(PyObject *ob) {
344344
assert(ob->ob_type != &PyLong_Type);
345345
assert(ob->ob_type != &PyBool_Type);
346-
PyVarObject *var_ob = _PyVarObject_CAST(ob);
347-
return var_ob->ob_size;
346+
return _PyVarObject_CAST(ob)->ob_size;
348347
}
349348
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
350349
# define Py_SIZE(ob) Py_SIZE(_PyObject_CAST(ob))
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Make the C API compatible with ``-Werror=declaration-after-statement``
2+
compiler flag again. Patch by Victor Stinner.

0 commit comments

Comments
 (0)