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.
Created on 2018年01月17日 14:32 by ukl, last changed 2022年04月11日 14:58 by admin.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| chr-OverflowError.patch | ukl, 2018年01月17日 14:32 | |||
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 5218 | closed | vstinner, 2018年01月17日 14:43 | |
| Messages (5) | |||
|---|---|---|---|
| msg310178 - (view) | Author: Uwe Kleine-König (ukl) * | Date: 2018年01月17日 14:32 | |
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.) |
|||
| msg310180 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2018年01月17日 14:44 | |
It's more an implementation issue. I proposed PR 5218 to also raise a ValueError on overflow. I propose to only change Python 3.7, and only Python 2.7 and 3.6 unchanged. |
|||
| msg310288 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2018年01月19日 21:10 | |
The message I get on Windows is OverflowError: Python int too large to convert to C long Given that the exception type is documented, making this a clear bug, I would be tempted to fix in 3.6 also. But your decision. |
|||
| msg310330 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2018年01月20日 08:04 | |
Perhaps this issue should be raised on Python-Dev, since it changes the old and well-known behavior of buildins. I think that ValueError is more appropriate, but in past we decided to keep OverflowError for compatibility. If change chr(), other code needs to be changed. "%c", PyUnicode_FromOrdinal(), PyUnicode_Format(), and possible the same for bytes. See also issue29833 and issue15988. |
|||
| msg406721 - (view) | Author: Irit Katriel (iritkatriel) * (Python committer) | Date: 2021年11月21日 14:53 | |
Still raising OVerflowError on 3.11: >>> print(chr(0x80000000)) Traceback (most recent call last): File "<stdin>", line 1, in <module> OverflowError: Python int too large to convert to C int |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:56 | admin | set | github: 76763 |
| 2021年11月22日 15:20:54 | mark.dickinson | set | nosy:
+ mark.dickinson |
| 2021年11月21日 15:29:18 | AlexWaygood | set | type: behavior |
| 2021年11月21日 14:53:23 | iritkatriel | set | nosy:
+ iritkatriel messages: + msg406721 versions: + Python 3.11, - Python 3.7 |
| 2018年01月20日 19:11:20 | serhiy.storchaka | link | issue29833 dependencies |
| 2018年01月20日 08:04:04 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages: + msg310330 |
| 2018年01月19日 21:10:11 | terry.reedy | set | nosy:
+ terry.reedy messages: + msg310288 |
| 2018年01月17日 14:44:42 | vstinner | set | nosy:
+ vstinner messages: + msg310180 versions: + Python 3.7, - Python 3.6 |
| 2018年01月17日 14:43:14 | vstinner | set | stage: patch review pull_requests: + pull_request5071 |
| 2018年01月17日 14:32:06 | ukl | create | |