gh-130104: Call __rpow__ in ternary pow() if necessary (GH-130251)

Previously it was only called in binary pow() and the binary
power operator.
This commit is contained in:
Serhiy Storchaka 2025-04-16 18:32:41 +03:00 committed by GitHub
parent 72da4a4458
commit 62ff86fa55
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 74 additions and 18 deletions

View file

@ -2440,12 +2440,12 @@ class Decimal(object):
return ans
def __rpow__(self, other, context=None):
def __rpow__(self, other, modulo=None, context=None):
"""Swaps self/other and returns __pow__."""
other = _convert_other(other)
if other is NotImplemented:
return other
return other.__pow__(self, context=context)
return other.__pow__(self, modulo, context=context)
def normalize(self, context=None):
"""Normalize- strip trailing 0s, change anything equal to 0 to 0e0"""