mirror of
https://github.com/python/cpython.git
synced 2025-11-15 16:09:29 +00:00
Avoid call_function_tail() for empty format str
Issue #27128, PyObject_CallFunction(), _PyObject_FastCall() and callmethod(): if the format string of parameters is empty, avoid the creation of an empty tuple: call _PyObject_FastCall() without parameters.
This commit is contained in:
parent
71aea8e981
commit
0d1a799343
1 changed files with 19 additions and 20 deletions
|
|
@ -2324,14 +2324,13 @@ PyObject_CallFunction(PyObject *callable, const char *format, ...)
|
||||||
return null_error();
|
return null_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format && *format) {
|
if (!format || !*format) {
|
||||||
va_start(va, format);
|
return _PyObject_FastCall(callable, NULL, 0, NULL);
|
||||||
args = Py_VaBuildValue(format, va);
|
|
||||||
va_end(va);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
args = PyTuple_New(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
va_start(va, format);
|
||||||
|
args = Py_VaBuildValue(format, va);
|
||||||
|
va_end(va);
|
||||||
if (args == NULL) {
|
if (args == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -2351,14 +2350,13 @@ _PyObject_CallFunction_SizeT(PyObject *callable, const char *format, ...)
|
||||||
return null_error();
|
return null_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format && *format) {
|
if (!format || !*format) {
|
||||||
va_start(va, format);
|
return _PyObject_FastCall(callable, NULL, 0, NULL);
|
||||||
args = _Py_VaBuildValue_SizeT(format, va);
|
|
||||||
va_end(va);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
args = PyTuple_New(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
va_start(va, format);
|
||||||
|
args = _Py_VaBuildValue_SizeT(format, va);
|
||||||
|
va_end(va);
|
||||||
if (args == NULL) {
|
if (args == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -2380,14 +2378,15 @@ callmethod(PyObject* func, const char *format, va_list va, int is_size_t)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format && *format) {
|
if (!format || !*format) {
|
||||||
if (is_size_t)
|
return _PyObject_FastCall(func, NULL, 0, NULL);
|
||||||
args = _Py_VaBuildValue_SizeT(format, va);
|
}
|
||||||
else
|
|
||||||
args = Py_VaBuildValue(format, va);
|
if (is_size_t) {
|
||||||
|
args = _Py_VaBuildValue_SizeT(format, va);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
args = PyTuple_New(0);
|
args = Py_VaBuildValue(format, va);
|
||||||
}
|
}
|
||||||
if (args == NULL) {
|
if (args == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue