New submission from Ken Jin <kenjin4...@gmail.com>:

I noticed that passing keyword arguments to types.GenericAlias's __new__ causes 
the interpreter to hard crash and exit due to an assertion failure:

import types
types.GenericAlias(bad=float)


Result:
Assertion failed: PyTuple_CheckExact(kwnames), file 
....\cpython\Python\getargs.c, line 2767

A simple fix is to just use _PyArg_NoKeywords instead of _PyArg_NoKwnames. 

Looking through the rest of the C code, it seems that apart from GenericAlias, 
only vectorcalls for various builtins use _PyArg_NoKwnames. However, they don't 
seem to be affected by the bug.

----------
components: Interpreter Core
messages: 382565
nosy: gvanrossum, kj
priority: normal
severity: normal
status: open
title: Passing keyword arguments to types.GenericAlias causes a hard crash
versions: Python 3.10, Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42576>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to