GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix `_tuplegetter()` accepting missing and keyword arguments by jseop-lim · Pull Request #1261 · oracle/graalpython

Conversation

@jseop-lim

@jseop-lim jseop-lim commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #1249

The tp_new signature of _collections._tuplegetter declared index and doc with no minimum and no positional-only count, so a call with fewer than two arguments built a getter for index 0, and both arguments could be passed by keyword. CPython's tuplegetter_new rejects keywords and requires exactly two positional arguments (_collectionsmodule.c.h#L607-L613).

AS-IS

>>> from collections import _tuplegetter
>>> _tuplegetter(0)
<_collections._tuplegetter object at 0x...>
>>> _tuplegetter()
<_collections._tuplegetter object at 0x...>
>>> _tuplegetter(0, doc=None)
<_collections._tuplegetter object at 0x...>

TO-BE

>>> _tuplegetter(0)
TypeError: _tuplegetter() missing 1 required positional argument: 'doc'
>>> _tuplegetter()
TypeError: _tuplegetter() missing 2 required positional arguments: 'index' and 'doc'
>>> _tuplegetter(0, doc=None)
TypeError: _tuplegetter() got some positional-only arguments passed as keyword arguments: 'doc'

(matching CPython's exception type; the messages are GraalPy's usual argument errors)

Changes

  • Add minNumOfPositionalArgs = 3, numOfPositionalOnlyArgs = 3 to the @SlotSignature of TupleGetterBuiltins.TupleGetterNode.
  • Add test_tuplegetter_arguments to tests/test_collections.py.

Testing

mx python-jvm on darwin-aarch64, then tests/test_collections.py (2 passed). The new test fails on the unpatched build. _tuplegetter(0, None) still creates the getter, _tuplegetter(1, 'd').__get__((10, 20)) returns 20, and namedtuple field access and field docs work as before.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jseop-lim
Require both _tuplegetter() arguments positionally
7e600e0
The tp_new signature declared no minimum and no positional-only
parameters, so _tuplegetter(0) and _tuplegetter() built a descriptor
from defaults, and index and doc were accepted as keywords. CPython
requires exactly two positional arguments and rejects keywords.

Signed-off-by: Jeongseop Lim <[email protected]>
@oracle-contributor-agreement oracle-contributor-agreement Bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Oct 31, 2026
msimacek
msimacek approved these changes Nov 9, 2026
View reviewed changes

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@msimacek msimacek msimacek approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Bug]: collections._tuplegetter accepts fewer than two arguments and keyword arguments

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@jseop-lim @msimacek
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.