[New-bugs-announce] [issue42527] UnicodeEncode error in BaseHttpRequestHandler class when send unicode data.
Yanfeng Wang
report at bugs.python.org
Tue Dec 1 11:40:04 EST 2020
New submission from Yanfeng Wang <wangyanfeng.p at gmail.com>:
My environment:
system: MacOS 10.15.x
python: 3.9.0
when I inherit the BaseHTTPRequestHandler class, and call the send_error(error_di, msg) method in my own class's do_GET override function:
the msg argument can't accept unicode string, an UnicodeEncodeError of 'latin-1' encoding error with ordinal call failed of out of range(255).
I tracked the code, and found in the implementation of this class, the data was sent through a encode call with 'latin-1' hard coded in. in the file: server.py near line 507.
BTW, I tried u'my string'.encode('utf-8'), and it didn't work, another TypeError in module html __init__.py line 19.
If I commented the original hard code 'latin-1' line and replace with the hard code encoding to 'utf-8', all will be fine.
Thanks for your read anyone who cares or takes care of this issue.
----------
components: Unicode
messages: 382268
nosy: ezio.melotti, vstinner, wangyanfeng.p
priority: normal
severity: normal
status: open
title: UnicodeEncode error in BaseHttpRequestHandler class when send unicode data.
type: behavior
versions: Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42527>
_______________________________________
More information about the New-bugs-announce
mailing list