mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +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();
|
||||
}
|
||||
|
||||
if (format && *format) {
|
||||
va_start(va, format);
|
||||
args = Py_VaBuildValue(format, va);
|
||||
va_end(va);
|
||||
}
|
||||
else {
|
||||
args = PyTuple_New(0);
|
||||
if (!format || !*format) {
|
||||
return _PyObject_FastCall(callable, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
va_start(va, format);
|
||||
args = Py_VaBuildValue(format, va);
|
||||
va_end(va);
|
||||
if (args == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -2351,14 +2350,13 @@ _PyObject_CallFunction_SizeT(PyObject *callable, const char *format, ...)
|
|||
return null_error();
|
||||
}
|
||||
|
||||
if (format && *format) {
|
||||
va_start(va, format);
|
||||
args = _Py_VaBuildValue_SizeT(format, va);
|
||||
va_end(va);
|
||||
}
|
||||
else {
|
||||
args = PyTuple_New(0);
|
||||
if (!format || !*format) {
|
||||
return _PyObject_FastCall(callable, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
va_start(va, format);
|
||||
args = _Py_VaBuildValue_SizeT(format, va);
|
||||
va_end(va);
|
||||
if (args == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -2380,14 +2378,15 @@ callmethod(PyObject* func, const char *format, va_list va, int is_size_t)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (format && *format) {
|
||||
if (is_size_t)
|
||||
args = _Py_VaBuildValue_SizeT(format, va);
|
||||
else
|
||||
args = Py_VaBuildValue(format, va);
|
||||
if (!format || !*format) {
|
||||
return _PyObject_FastCall(func, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
if (is_size_t) {
|
||||
args = _Py_VaBuildValue_SizeT(format, va);
|
||||
}
|
||||
else {
|
||||
args = PyTuple_New(0);
|
||||
args = Py_VaBuildValue(format, va);
|
||||
}
|
||||
if (args == NULL) {
|
||||
return NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue