mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
bpo-37337: Add _PyObject_VectorcallMethod() (GH-14228)
This commit is contained in:
parent
b4bee03087
commit
b1263d5a60
7 changed files with 105 additions and 33 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue