[Python-Dev] A type of out-of-range exception for %c (original) (raw)
Serhiy Storchaka storchaka at gmail.com
Sun Jun 23 20:59:37 CEST 2013
- Previous message: [Python-Dev] PEP 445 delegate
- Next message: [Python-Dev] A type of out-of-range exception for %c
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Currently %c formatting raises OverflowError if an argument is out of range.
'%c' % 1114112 Traceback (most recent call last): File "", line 1, in OverflowError: %c arg not in range(0x110000) '{:c}'.format(1114112) Traceback (most recent call last): File "", line 1, in OverflowError: %c arg not in range(0x110000)
The same for PyUnicode_Format(), PyUnicode_FromFromat() and PyUnicode_FromFromatV() in C API.
But chr() raises ValueError.
chr(1114112) Traceback (most recent call last): File "", line 1, in ValueError: chr() arg not in range(0x110000)
And ValueError looks more suitable, because it is not really an overflow (limitation of the C language, or a C type). Can we change an exception type for %c formatting from OverflowError to ValueError?
- Previous message: [Python-Dev] PEP 445 delegate
- Next message: [Python-Dev] A type of out-of-range exception for %c
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]