New submission from Uwe Kleine-König <uwe+pyt...@kleine-koenig.org>:

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.)

----------
components: Interpreter Core
files: chr-OverflowError.patch
keywords: patch
messages: 310178
nosy: ukl
priority: normal
severity: normal
status: open
title: chr raises OverflowError
versions: Python 3.6
Added file: https://bugs.python.org/file47390/chr-OverflowError.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32582>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to