Issue 27092: ord() raises TypeError on string/bytes input (original) (raw)
Hi, is there any reason why ord() raises a TypeError instead of ValueError on string/bytes input with wrong length?
The chr() function will raise a ValueError on negative integers such as chr(-1).
Required behaviour:
try: n = ord(input_string) except ValueError as e: # it's a string/bytes-string, process potential escape sequence and # get an ordinal number of decoded escape sequence, otherwise raise ...
with kind regards, Chris