]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-116869: Make C API compatible with ISO C90 (#116950)
authorVictor Stinner <vstinner@python.org>
Mon, 18 Mar 2024 19:16:58 +0000 (20:16 +0100)
committerGitHub <noreply@github.com>
Mon, 18 Mar 2024 19:16:58 +0000 (20:16 +0100)
Make the C API compatible with -Werror=declaration-after-statement
compiler flag again.

Include/cpython/longintrepr.h
Include/object.h
Misc/NEWS.d/next/C API/2024-03-18-09-58-46.gh-issue-116869.LFDVKM.rst [new file with mode: 0644]

index f037c7bb90deda56ea3553bab00c04041f6247d6..3246908ba982e217d1b3987dbae9884f075c35ad 100644 (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];
 }
 
index 34141af7b7f7ef752fb457b4dfaec5365c4a4fa6..b0c0dba06ca139f74653d0b48d937b2058270435 100644 (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))
diff --git a/Misc/NEWS.d/next/C API/2024-03-18-09-58-46.gh-issue-116869.LFDVKM.rst b/Misc/NEWS.d/next/C API/2024-03-18-09-58-46.gh-issue-116869.LFDVKM.rst
new file mode 100644 (file)
index 0000000..9b9d943
--- /dev/null
@@ -0,0 +1,2 @@
+Make the C API compatible with ``-Werror=declaration-after-statement``
+compiler flag again. Patch by Victor Stinner.