]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-119594: Improve pow(fraction.Fraction(), b, modulo) error message (#119593)
authorWim Jeantine-Glenn <hey@wimglenn.com>
Wed, 29 May 2024 17:46:20 +0000 (12:46 -0500)
committerGitHub <noreply@github.com>
Wed, 29 May 2024 17:46:20 +0000 (13:46 -0400)
commitfcca08ec2f48f4ba5ba1d4690fb39b1efe630944
treeb874582eadea61278f502ed0219e92e5b4fd077e
parentbf4ff3ad2e362801e87c85fffd9e140b774cef26
gh-119594: Improve pow(fraction.Fraction(), b, modulo) error message (#119593)

If one calls pow(fractions.Fraction, x, module) with modulo not None, the error message now says that the types are incompatible rather than saying pow only takes 2 arguments.  Implemented by having fractions.Fraction __pow__ accept optional modulo argument and return NotImplemented if not None.  pow() then raises with appropriate message.
---------

Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
Lib/fractions.py
Lib/test/test_fractions.py
Misc/NEWS.d/next/Library/2024-05-26-22-22-51.gh-issue-119594.fnQNM8.rst [new file with mode: 0644]