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.

Author cwr
Recipients cwr, ezio.melotti, vstinner
Date 2016-05-23.12:53:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1464008039.38.0.432855281585.issue27092@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2016-05-23 12:53:59cwrsetrecipients: + cwr, vstinner, ezio.melotti
2016-05-23 12:53:59cwrsetmessageid: <1464008039.38.0.432855281585.issue27092@psf.upfronthosting.co.za>
2016-05-23 12:53:59cwrlinkissue27092 messages
2016-05-23 12:53:59cwrcreate