gh-119838: Treat Fraction as a real value in mixed arithmetic operations with complex (GH-119839)

This commit is contained in:
Serhiy Storchaka 2024-06-03 12:29:01 +03:00 committed by GitHub
parent 70934fb469
commit d7fcaa73b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 6 deletions

View file

@ -668,7 +668,7 @@ def forward(a, b):
elif isinstance(b, float):
return fallback_operator(float(a), b)
elif handle_complex and isinstance(b, complex):
return fallback_operator(complex(a), b)
return fallback_operator(float(a), b)
else:
return NotImplemented
forward.__name__ = '__' + fallback_operator.__name__ + '__'
@ -681,7 +681,7 @@ def reverse(b, a):
elif isinstance(a, numbers.Real):
return fallback_operator(float(a), float(b))
elif handle_complex and isinstance(a, numbers.Complex):
return fallback_operator(complex(a), complex(b))
return fallback_operator(complex(a), float(b))
else:
return NotImplemented
reverse.__name__ = '__r' + fallback_operator.__name__ + '__'