◐ Shell
clean mode source ↗

Message 310178 - Python tracker

Hello,

the description for chr (from https://docs.python.org/3/library/functions.html#chr) reads as:

        Return the string representing a character whose Unicode code
        point is the integer i. [...] The valid range for the argument
        is from 0 through 1,114,111 (0x10FFFF in base 16). ValueError
        will be raised if i is outside that range.

If however a value > 0x7fffffff (or < -0x80000000) is provided, the function raises an Overflow error:

        $ python3 -c 'print(chr(0x80000000))'
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
        OverflowError: signed integer is greater than maximum

This is either a documentation problem or (more like) an implementation issue. I attached a patch that fixes the issue for me. (I'm not sure however if I should call PyErr_Clear() before raising ValueError.)