mirror of
https://github.com/python/cpython.git
synced 2025-11-02 06:31:29 +00:00
gh-119838: Treat Fraction as a real value in mixed arithmetic operations with complex (GH-119839)
This commit is contained in:
parent
70934fb469
commit
d7fcaa73b7
3 changed files with 6 additions and 6 deletions
|
|
@ -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__ + '__'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue