Skip to content

bpo-38237: Fix "versionchanged" for pow named arguments #19042

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

Merged

Conversation

mdickinson
Copy link
Member

@mdickinson mdickinson commented Mar 17, 2020

The ability to use named arguments in "pow" was introduced in Python 3.8, not Python 3.9.

https://bugs.python.org/issue38237

The ability to use named arguments in "pow" was introduced in Python 3.8, not Python 3.9. See https://bugs.python.org/issue38237
@ammaraskar
Copy link
Member

Thanks Mark! Looks like the backport to 3.8 was added after my original PR so this got missed. Should https://github.com/python/cpython/blob/master/Doc/whatsnew/3.8.rst be updated as well?

Probably an entry near the:

For integers, the three-argument form of the :func:pow function now permits the exponent to be negative in the case where the base is relatively prime to the modulus. It then computes a modular inverse to the base when the

and

One use case for this notation is that it allows pure Python functions to fully emulate behaviors of existing C coded functions. For example, the built-in :func:pow function does not accept keyword arguments:

def pow(x, y, z=None, /):
   "Emulate the built in pow() function"
  r = x ** y
   return r if z is None else r%z

updated to divmod to match the original PR?

@mdickinson
Copy link
Member Author

Should https://github.com/python/cpython/blob/master/Doc/whatsnew/3.8.rst be updated as well?

It should, but it looks as though there isn't good agreement on the issue about how. So we may as well get this uncontroversial fix in, and then make a follow-up PR once we've decided what to do about the what's new document.

Copy link
Contributor

@aeros aeros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; I locally confirmed that kwarg support for pow() was indeed added in 3.8.

Python 3.8.2 (default, Feb 26 2020, 22:21:03) 
[GCC 9.2.1 20200130] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> pow(base=2, exp=10)
1024
Python 3.7.7+ (heads/3.7:4e3a7f9205, Mar 19 2020, 00:23:06) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> pow(base=2, exp=10)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: pow() takes no keyword arguments

@mdickinson mdickinson merged commit c691f20 into python:master Mar 19, 2020
@miss-islington
Copy link
Contributor

Thanks @mdickinson for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 19, 2020
The ability to use named arguments in "pow" was introduced in Python 3.8, not Python 3.9. See https://bugs.python.org/issue38237
(cherry picked from commit c691f20)

Co-authored-by: Mark Dickinson <[email protected]>
@bedevere-bot
Copy link

GH-19079 is a backport of this pull request to the 3.8 branch.

@mdickinson
Copy link
Member Author

@ammaraskar @aeros Thanks. I'll aim to find some time this weekend to look at the "what's new" part of the issue (though if someone else gets there first, even better!).

mdickinson added a commit that referenced this pull request Mar 19, 2020
The ability to use named arguments in "pow" was introduced in Python 3.8, not Python 3.9. See https://bugs.python.org/issue38237
(cherry picked from commit c691f20)

Co-authored-by: Mark Dickinson <[email protected]>
@mdickinson mdickinson deleted the fix-pow-named-arguments-version-changed branch March 19, 2020 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants