Skip to content

Python implementation of functools.reduce accepts keyword arguments, while the C implementation does not #121676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Eclips4 opened this issue Jul 13, 2024 · 0 comments
Labels
3.14 bugs and security fixes type-bug An unexpected behavior, bug, or error

Comments

@Eclips4
Copy link
Member

Eclips4 commented Jul 13, 2024

Bug report

Bug description:

Steps to reproduce:

printf '*disabled*\n_functools\n' > Modules/Setup.local
./configure --with-pydebug && make -j
./python
Python 3.14.0a0 (heads/main:dc03ce797a, Jul 13 2024, 09:31:53) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import functools
>>> functools.reduce(function=lambda x, y: x + y, sequence=[1, 2, 3, 4, 5])
15

Our docs mention functools.reduce as a function that accepts positional-only arguments.

I have a PR ready to fix that.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

@Eclips4 Eclips4 added the type-bug An unexpected behavior, bug, or error label Jul 13, 2024
@Eclips4 Eclips4 added 3.12 only security fixes 3.13 bugs and security fixes 3.14 bugs and security fixes and removed 3.12 only security fixes 3.13 bugs and security fixes labels Jul 13, 2024
Eclips4 added a commit that referenced this issue Jan 1, 2025
…n of ``functools.reduce`` is called with `function` or `sequence` as a keyword args (#121677)

Python implementation of `functools` allows calling `reduce`
with `function` or `sequence` as keyword args. This doesn't
match behavior of our C accelerator and our documentation
for `functools.reduce` states that `function`and `sequence`
are positional-only arguments.

Now calling a Python implementation of `functools.reduce`
with `function` or `sequence` as keyword args would raise
a `DeprecationWarning` and is planned to be prohibited in
Python 3.16.


Co-authored-by: Victor Stinner <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>
@Eclips4 Eclips4 closed this as completed Jan 1, 2025
srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this issue Jan 8, 2025
…ntation of ``functools.reduce`` is called with `function` or `sequence` as a keyword args (python#121677)

Python implementation of `functools` allows calling `reduce`
with `function` or `sequence` as keyword args. This doesn't
match behavior of our C accelerator and our documentation
for `functools.reduce` states that `function`and `sequence`
are positional-only arguments.

Now calling a Python implementation of `functools.reduce`
with `function` or `sequence` as keyword args would raise
a `DeprecationWarning` and is planned to be prohibited in
Python 3.16.


Co-authored-by: Victor Stinner <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.14 bugs and security fixes type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant