summaryrefslogtreecommitdiffstats
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
authorJeroen Demeyer <J.Demeyer@UGent.be>2019-06-28 09:49:00 (GMT)
committerInada Naoki <songofacandy@gmail.com>2019-06-28 09:49:00 (GMT)
commitb1263d5a60d3f7ab02dd28409fff59b3815a3f67 (patch)
treed2b48c8ffcf6b8d4c042495e0b8888b7deda086e /Python/sysmodule.c
parentb4bee03087a3c70cb040e2ce569c828860ed8e87 (diff)
downloadcpython-b1263d5a60d3f7ab02dd28409fff59b3815a3f67.zip
cpython-b1263d5a60d3f7ab02dd28409fff59b3815a3f67.tar.gz
cpython-b1263d5a60d3f7ab02dd28409fff59b3815a3f67.tar.bz2
bpo-37337: Add _PyObject_VectorcallMethod() (GH-14228)
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r--Python/sysmodule.c27
1 files changed, 7 insertions, 20 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index b200318..1c57561 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -3110,30 +3110,17 @@ PySys_SetArgv(int argc, wchar_t **argv)
static int
sys_pyfile_write_unicode(PyObject *unicode, PyObject *file)
{
- PyObject *writer = NULL, *result = NULL;
- int err;
-
if (file == NULL)
return -1;
-
- writer = _PyObject_GetAttrId(file, &PyId_write);
- if (writer == NULL)
- goto error;
-
- result = PyObject_CallFunctionObjArgs(writer, unicode, NULL);
+ assert(unicode != NULL);
+ PyObject *margs[2] = {file, unicode};
+ PyObject *result = _PyObject_VectorcallMethodId(&PyId_write, margs,
+ 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
if (result == NULL) {
- goto error;
- } else {
- err = 0;
- goto finally;
+ return -1;
}
-
-error:
- err = -1;
-finally:
- Py_XDECREF(writer);
- Py_XDECREF(result);
- return err;
+ Py_DECREF(result);
+ return 0;
}
static int