[New-bugs-announce] [issue27092] ord() raises TypeError in string input

Christoph Wruck report at bugs.python.org
Mon May 23 08:53:59 EDT 2016


New submission from Christoph Wruck:

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

----------
components: Unicode
messages: 266142
nosy: cwr, ezio.melotti, haypo
priority: normal
severity: normal
status: open
title: ord() raises TypeError in string input
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27092>
_______________________________________


More information about the New-bugs-announce mailing list