This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author auscompgeek
Recipients auscompgeek
Date 2020-03-06.02:59:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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.


>>> import math
>>> from fractions import Fraction
>>> float(Fraction(-1, 1))  # this is needed to avoid an AttributeError?
>>> 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/", 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:01auscompgeeksetrecipients: + auscompgeek
2020-03-06 02:59:01auscompgeeksetmessageid: <>
2020-03-06 02:59:01auscompgeeklinkissue39871 messages
2020-03-06 02:59:01auscompgeekcreate