You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: collections._tuplegetter accepts fewer than two arguments and keyword arguments #1249
_collections._tuplegetter treats index and doc as optional keyword-capable parameters. A call with fewer than two arguments builds a getter for index 0, while CPython requires exactly two positional arguments and rejects keywords.
Operating system
macOS
CPU architecture
ARM64
GraalPy version
master a3009f9 (Python 3.13.14); also reproduced on 25.0.2 (Python 3.12.8)
_tuplegetter() with no arguments also succeeds, and _tuplegetter(0, doc=None) and _tuplegetter(index=0, doc=None) succeed where CPython raises TypeError: _tuplegetter() takes no keyword arguments.
Root Cause
The tp_new of TupleGetterNode declares @SlotSignature(name = J_TUPLE_GETTER, parameterNames = {"cls", "index", "doc"}) with no minimum or positional-only count (TupleGetterBuiltins.java#L97-L99), so both arguments are optional and can be passed by keyword. CPython's tuplegetter_new rejects keywords and then calls _PyArg_CheckPositional("_tuplegetter", nargs, 2, 2) (_collectionsmodule.c.h#L607-L613).
Fix Suggestion
Add minNumOfPositionalArgs = 3, numOfPositionalOnlyArgs = 3 to that @SlotSignature.
Activity