Message363477
If math.copysign(x, y) is passed an x that cannot be converted to a float and a y that implements __float__() in Python, math.copysign() will raise a SystemError from the TypeError resulting from the attempted float conversion of x.
math.copysign() should probably return immediately if converting the first argument to a float raises an error.
Example:
>>> import math
>>> from fractions import Fraction
>>> float(Fraction(-1, 1)) # this is needed to avoid an AttributeError?
-1.0
>>> math.copysign((-1) ** 0.5, Fraction(-1, 1))
TypeError: can't convert complex to float
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.8/numbers.py", line 291, in __float__
return self.numerator / self.denominator
SystemError: PyEval_EvalFrameEx returned a result with an error set |
|
Date |
User |
Action |
Args |
2020-03-06 02:59:01 | auscompgeek | set | recipients:
+ auscompgeek |
2020-03-06 02:59:01 | auscompgeek | set | messageid: <1583463541.57.0.123228500554.issue39871@roundup.psfhosted.org> |
2020-03-06 02:59:01 | auscompgeek | link | issue39871 messages |
2020-03-06 02:59:01 | auscompgeek | create | |
|