[Python-checkins] Update ga_new to use _PyArg_CheckPositional and _PyArg_NoKwnames (GH-19679)

Dong-hee Na webhook-mailer at python.org
Thu Apr 23 12:26:10 EDT 2020


https://github.com/python/cpython/commit/02e4484f19304a0a5f484f06a3fa441c6fb6073a
commit: 02e4484f19304a0a5f484f06a3fa441c6fb6073a
branch: master
author: Dong-hee Na <donghee.na92 at gmail.com>
committer: GitHub <noreply at github.com>
date: 2020-04-24T01:25:53+09:00
summary:

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

files:
M Objects/genericaliasobject.c

diff --git a/Objects/genericaliasobject.c b/Objects/genericaliasobject.c
index b8ad4d7014b0c..a56bdda38177f 100644
--- a/Objects/genericaliasobject.c
+++ b/Objects/genericaliasobject.c
@@ -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);



More information about the Python-checkins mailing list