Update ga_new to use _PyArg_CheckPositional and _PyArg_NoKwnames (GH-19679)

This commit is contained in:
Dong-hee Na 2020-04-24 01:25:53 +09:00 committed by GitHub
parent ebebb6429c
commit 02e4484f19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 4 deletions

View File

@ -438,12 +438,10 @@ static PyGetSetDef ga_properties[] = {
static PyObject *
ga_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
if (kwds != NULL && PyDict_GET_SIZE(kwds) != 0) {
PyErr_SetString(PyExc_TypeError, "GenericAlias does not support keyword arguments");
if (!_PyArg_NoKwnames("GenericAlias", kwds)) {
return NULL;
}
if (PyTuple_GET_SIZE(args) != 2) {
PyErr_SetString(PyExc_TypeError, "GenericAlias expects 2 positional arguments");
if (!_PyArg_CheckPositional("GenericAlias", PyTuple_GET_SIZE(args), 2, 2)) {
return NULL;
}
PyObject *origin = PyTuple_GET_ITEM(args, 0);