[New-bugs-announce] [issue18570] OverflowError during division: wrong message

Marco Buttu report at bugs.python.org
Sat Jul 27 13:31:25 CEST 2013


New submission from Marco Buttu:

When the integer division result is too large to converto to float, and the operands are inside the limits, the result is `inf` or `-inf`::

    >>> 2**1023 / 2**-3
    inf
    >>> 2**1022 / 2**-4
    inf
    >>> 2**1023 / 2**-1074
    inf

When both the result and an operand are too large to converto to float, we raise an OverflowError::

    >>> 2**1028 / 2**-2
    Traceback (most recent call last):
      File "<input>", line 1, in <module>
    OverflowError: long int too large to convert to float

The message says: "long int too large to convert to float". I think in Python 3 it should be "int too large to convert...". In any case, the most important thing is that in the same situation we get a different message [1]_::

    >>> 2**1032 / 2**2
    Traceback (most recent call last):
      File "<input>", line 1, in <module>
    OverflowError: integer division result too large for a float

and I think is it muddleheaded, because it should be "long int too large to convert to float", as we got in the case `2**1028 / 2**-2`. I think we should never show "integer division result too large for a float", but just:

* `inf` or `-inf` when the operands are inside the limits, but the result 
  does not
* `OverflowError: long int too large to convert to float` when the result, 
  and at least one operand, are out of range.


.. [1] In this situation, we get the message "OverflowError: integer division result too large for a float" only when the denominator exponent is positive.

----------
messages: 193783
nosy: marco.buttu
priority: normal
severity: normal
status: open
title: OverflowError during division: wrong message
type: behavior
versions: Python 3.1, Python 3.2, Python 3.3, Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18570>
_______________________________________


More information about the New-bugs-announce mailing list