Skip to content

Preserve Placeholder binding when currying partial objects - #653

Open
skyon0522-ai wants to merge 1 commit into
pytoolz:masterfrom
skyon0522-ai:fix-curry-placeholder-652-20261023
Open

skyon0522-ai wants to merge 1 commit into
pytoolz:masterfrom
skyon0522-ai:fix-curry-placeholder-652-20261023

Conversation

@skyon0522-ai

Copy link
Copy Markdown

Fixes #652.

On Python 3.14, curry concatenates a partial object's stored arguments as if they were a bound prefix. For f(a, b, c) returning its arguments and base = partial(f, Placeholder, 2), curry(base, 1)(3) consequently returns (3, 2, 1) instead of (1, 2, 3). Staged calls can raise before all arguments are supplied, and the reported signature drops the placeholder parameter.

Use stdlib partial composition to fill the stored slots, and use the effective partial signature when checking remaining arguments and building the curried signature. Placeholder detection uses identity so ordinary argument equality is not invoked.

Regression coverage includes constructor binding, bind, staged and idempotent currying, multiple interior slots, signature binding, ordinary argument equality, and propagation of a genuine function-body TypeError.

Validation against 451af60dec590a6010e2babdbf391ea8f815122f, using pytest 9.1.1 on Windows:

  • Before the implementation change, the eight new cases produced six regression failures and two passing controls.
  • CPython 3.14.9: test_functoolz.py and test_serialization.py passed all 57 tests. The package tests with --doctest-modules then passed 276 tests, skipped one existing doctest, and explicitly deselected one metadata test.
  • CPython 3.12.14: the same two test files passed 49 tests, with eight version-dependent skips.
  • The original six-call reproducer returns the expected tuples, and its signature accepts the valid argument list.
  • git diff --check passed.

The broader run deselected toolz/tests/test_package.py::test_has_version because this direct-source test environment has no installed Toolz distribution metadata. That test and an installed-distribution build were not validated. The reported runs reused an existing pytest/dependency environment without installing packages.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

curry can reorder Placeholder arguments on Python 3.14

1 participant