[3.13] gh-130230: Fix crash in pow() with only Decimal third argument (GH-130237) (GH-130246)

(cherry picked from commit b93b7e566e)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-02-18 12:18:37 +01:00 committed by GitHub
parent fc1c9f884e
commit 5d83b6c160
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 41 additions and 1 deletions

View file

@ -4458,6 +4458,15 @@ class Coverage:
self.assertIs(Decimal("NaN").fma(7, 1).is_nan(), True)
# three arg power
self.assertEqual(pow(Decimal(10), 2, 7), 2)
if self.decimal == C:
self.assertEqual(pow(10, Decimal(2), 7), 2)
self.assertEqual(pow(10, 2, Decimal(7)), 2)
else:
# XXX: Three-arg power doesn't use __rpow__.
self.assertRaises(TypeError, pow, 10, Decimal(2), 7)
# XXX: There is no special method to dispatch on the
# third arg of three-arg power.
self.assertRaises(TypeError, pow, 10, 2, Decimal(7))
# exp
self.assertEqual(Decimal("1.01").exp(), 3)
# is_normal