bpo-37337: Add _PyObject_VectorcallMethod() (GH-14228)

This commit is contained in:
Jeroen Demeyer 2019-06-28 11:49:00 +02:00 committed by Inada Naoki
parent b4bee03087
commit b1263d5a60
7 changed files with 105 additions and 33 deletions

View file

@ -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