]> granicus.if.org Git - python/commitdiff
bpo-37191: Avoid declaration-after-statement in header included from Python.h (GH...
authorPetr Viktorin <pviktori@redhat.com>
Fri, 7 Jun 2019 16:31:56 +0000 (18:31 +0200)
committerVictor Stinner <vstinner@redhat.com>
Fri, 7 Jun 2019 16:31:56 +0000 (18:31 +0200)
Include/cpython/abstract.h
Misc/NEWS.d/next/C API/2019-06-07-10-47-37.bpo-37191.iGL1_K.rst [new file with mode: 0644]

index 7ab2045923d83de03eef5cf6aeed503129f67024..2ea3209bca1098f11b1a1a78e43280eea79459c9 100644 (file)
@@ -81,13 +81,14 @@ static inline vectorcallfunc
 _PyVectorcall_Function(PyObject *callable)
 {
     PyTypeObject *tp = Py_TYPE(callable);
+    Py_ssize_t offset = tp->tp_vectorcall_offset;
+    vectorcallfunc *ptr;
     if (!PyType_HasFeature(tp, _Py_TPFLAGS_HAVE_VECTORCALL)) {
         return NULL;
     }
     assert(PyCallable_Check(callable));
-    Py_ssize_t offset = tp->tp_vectorcall_offset;
     assert(offset > 0);
-    vectorcallfunc *ptr = (vectorcallfunc *)(((char *)callable) + offset);
+    ptr = (vectorcallfunc*)(((char *)callable) + offset);
     return *ptr;
 }
 
@@ -114,14 +115,16 @@ static inline PyObject *
 _PyObject_Vectorcall(PyObject *callable, PyObject *const *args,
                      size_t nargsf, PyObject *kwnames)
 {
+    PyObject *res;
+    vectorcallfunc func;
     assert(kwnames == NULL || PyTuple_Check(kwnames));
     assert(args != NULL || PyVectorcall_NARGS(nargsf) == 0);
-    vectorcallfunc func = _PyVectorcall_Function(callable);
+    func = _PyVectorcall_Function(callable);
     if (func == NULL) {
         Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
         return _PyObject_MakeTpCall(callable, args, nargs, kwnames);
     }
-    PyObject *res = func(callable, args, nargsf, kwnames);
+    res = func(callable, args, nargsf, kwnames);
     return _Py_CheckFunctionResult(callable, res, NULL);
 }
 
diff --git a/Misc/NEWS.d/next/C API/2019-06-07-10-47-37.bpo-37191.iGL1_K.rst b/Misc/NEWS.d/next/C API/2019-06-07-10-47-37.bpo-37191.iGL1_K.rst
new file mode 100644 (file)
index 0000000..7cb296d
--- /dev/null
@@ -0,0 +1,3 @@
+Python.h does not need compiler support for intermingled declarations (GCC's
+``-Wdeclaration-after-statement``), which were added in 3.8.0 Beta 1. Note
+that in Python 3.9, intermingled declarations will be needed again.