summaryrefslogtreecommitdiffstats
path: root/Include/cpython
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2019-06-07 16:31:56 (GMT)
committerVictor Stinner <vstinner@redhat.com>2019-06-07 16:31:56 (GMT)
commit9689f80e61e5863668a562793ebb85031ef9fd3e (patch)
tree351f125f258753b9c84a7ed6ff52d30907a19d68 /Include/cpython
parent5effd10bf14ab0a8a6695100aaf0b687eca68e6d (diff)
downloadcpython-9689f80e61e5863668a562793ebb85031ef9fd3e.zip
cpython-9689f80e61e5863668a562793ebb85031ef9fd3e.tar.gz
cpython-9689f80e61e5863668a562793ebb85031ef9fd3e.tar.bz2
bpo-37191: Avoid declaration-after-statement in header included from Python.h (GH-13887)
Diffstat (limited to 'Include/cpython')
-rw-r--r--Include/cpython/abstract.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h
index 7ab2045..2ea3209 100644
--- a/Include/cpython/abstract.h
+++ b/Include/cpython/abstract.h
@@ -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);
}