mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
bpo-37191: Avoid declaration-after-statement in header included from Python.h (GH-13887)
This commit is contained in:
parent
5effd10bf1
commit
9689f80e61
2 changed files with 10 additions and 4 deletions
|
@ -81,13 +81,14 @@ static inline vectorcallfunc
|
||||||
_PyVectorcall_Function(PyObject *callable)
|
_PyVectorcall_Function(PyObject *callable)
|
||||||
{
|
{
|
||||||
PyTypeObject *tp = Py_TYPE(callable);
|
PyTypeObject *tp = Py_TYPE(callable);
|
||||||
|
Py_ssize_t offset = tp->tp_vectorcall_offset;
|
||||||
|
vectorcallfunc *ptr;
|
||||||
if (!PyType_HasFeature(tp, _Py_TPFLAGS_HAVE_VECTORCALL)) {
|
if (!PyType_HasFeature(tp, _Py_TPFLAGS_HAVE_VECTORCALL)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
assert(PyCallable_Check(callable));
|
assert(PyCallable_Check(callable));
|
||||||
Py_ssize_t offset = tp->tp_vectorcall_offset;
|
|
||||||
assert(offset > 0);
|
assert(offset > 0);
|
||||||
vectorcallfunc *ptr = (vectorcallfunc *)(((char *)callable) + offset);
|
ptr = (vectorcallfunc*)(((char *)callable) + offset);
|
||||||
return *ptr;
|
return *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,14 +115,16 @@ static inline PyObject *
|
||||||
_PyObject_Vectorcall(PyObject *callable, PyObject *const *args,
|
_PyObject_Vectorcall(PyObject *callable, PyObject *const *args,
|
||||||
size_t nargsf, PyObject *kwnames)
|
size_t nargsf, PyObject *kwnames)
|
||||||
{
|
{
|
||||||
|
PyObject *res;
|
||||||
|
vectorcallfunc func;
|
||||||
assert(kwnames == NULL || PyTuple_Check(kwnames));
|
assert(kwnames == NULL || PyTuple_Check(kwnames));
|
||||||
assert(args != NULL || PyVectorcall_NARGS(nargsf) == 0);
|
assert(args != NULL || PyVectorcall_NARGS(nargsf) == 0);
|
||||||
vectorcallfunc func = _PyVectorcall_Function(callable);
|
func = _PyVectorcall_Function(callable);
|
||||||
if (func == NULL) {
|
if (func == NULL) {
|
||||||
Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
|
Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
|
||||||
return _PyObject_MakeTpCall(callable, args, nargs, kwnames);
|
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);
|
return _Py_CheckFunctionResult(callable, res, 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.
|
Loading…
Add table
Add a link
Reference in a new issue