homepage

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.

classification
Title: ord() raises TypeError on string/bytes input
Type: behavior Stage:
Components: Unicode Versions: Python 3.4
process
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
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
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:
http://bugs.python.org/issue27008 
History
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

AltStyle によって変換されたページ (->オリジナル) /