summaryrefslogtreecommitdiffstats
path: root/Objects/abstract.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-08-19 15:04:54 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-08-19 15:04:54 (GMT)
commit0d1a799343dd956c8e4a1d6e0ac3fa9ac007704e (patch)
tree40c101a07f811975f038c1ff9770d2c4474b5765 /Objects/abstract.c
parent71aea8e98176c333a8fc4710b3765d72ea6b04c5 (diff)
downloadcpython-0d1a799343dd956c8e4a1d6e0ac3fa9ac007704e.zip
cpython-0d1a799343dd956c8e4a1d6e0ac3fa9ac007704e.tar.gz
cpython-0d1a799343dd956c8e4a1d6e0ac3fa9ac007704e.tar.bz2
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.
Diffstat (limited to 'Objects/abstract.c')
-rw-r--r--Objects/abstract.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index cec47bf..aaa6fc8 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -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;