Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 02e4484

Browse files
authored
Update ga_new to use _PyArg_CheckPositional and _PyArg_NoKwnames (GH-19679)
1 parent ebebb64 commit 02e4484

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

Objects/genericaliasobject.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,12 +438,10 @@ static PyGetSetDef ga_properties[] = {
438438
static PyObject *
439439
ga_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
440440
{
441-
if (kwds != NULL && PyDict_GET_SIZE(kwds) != 0) {
442-
PyErr_SetString(PyExc_TypeError, "GenericAlias does not support keyword arguments");
441+
if (!_PyArg_NoKwnames("GenericAlias", kwds)) {
443442
return NULL;
444443
}
445-
if (PyTuple_GET_SIZE(args) != 2) {
446-
PyErr_SetString(PyExc_TypeError, "GenericAlias expects 2 positional arguments");
444+
if (!_PyArg_CheckPositional("GenericAlias", PyTuple_GET_SIZE(args), 2, 2)) {
447445
return NULL;
448446
}
449447
PyObject *origin = PyTuple_GET_ITEM(args, 0);

0 commit comments

Comments
 (0)