bpo-42576: Raise TypeError when passing in keyword arguments to GenericAlias (GH-23656)


Use `_PyArg_NoKeywords` instead of `_PyArg_NoKwnames` when checking the `kwds` tuple when creating `GenericAlias`. This fixes an interpreter crash when passing in keyword arguments to `GenericAlias`'s constructor.

Needs backport to 3.9.

Automerge-Triggered-By: GH:gvanrossum
(cherry picked from commit 804d6893b801e8f30318afc38c20d4d0e6161db3)

Co-authored-by: kj <28750310+Fidget-Spinner@users.noreply.github.com>
diff --git a/Objects/genericaliasobject.c b/Objects/genericaliasobject.c
index 4b6c8c6..c5a81a5 100644
--- a/Objects/genericaliasobject.c
+++ b/Objects/genericaliasobject.c
@@ -566,7 +566,7 @@
 static PyObject *
 ga_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
-    if (!_PyArg_NoKwnames("GenericAlias", kwds)) {
+    if (!_PyArg_NoKeywords("GenericAlias", kwds)) {
         return NULL;
     }
     if (!_PyArg_CheckPositional("GenericAlias", PyTuple_GET_SIZE(args), 2, 2)) {