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.

Title: ord() raises TypeError on string/bytes input
Type: behavior Stage:
Components: Unicode Versions: Python 3.4
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: cwr, ezio.melotti, serhiy.storchaka, vstinner, xiang.zhang
Priority: normal Keywords:

Created on 2016-05-23 12:53 by cwr, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg266142 - (view) Author: Christoph Wruck (cwr) Date: 2016-05-23 12:53
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:

    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,
msg266144 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-05-23 13:14
Once I also mentioned about this in another thread, issue27008, I created and Serhiy gave me a response. You can have a look at that.
msg266147 - (view) Author: Christoph Wruck (cwr) Date: 2016-05-23 13:41
closed as redundant to:
Date User Action Args
2022-04-11 14:58:31adminsetgithub: 71279
2016-05-23 13:41:26cwrsetstatus: open -> closed
resolution: not a bug
messages: + msg266147

title: ord() raises TypeError in string input -> ord() raises TypeError on string/bytes input
2016-05-23 13:27:05xiang.zhangsetnosy: + serhiy.storchaka
2016-05-23 13:14:42xiang.zhangsetnosy: + xiang.zhang
messages: + msg266144
2016-05-23 13:03:38cwrsettype: enhancement -> behavior
2016-05-23 13:03:00cwrsettype: enhancement
2016-05-23 12:53:59cwrcreate