[New-bugs-announce] [issue5263] Error printing UTF-8 decoded text
Lovely Grace
report at bugs.python.org
Sat Feb 14 22:33:35 CET 2009
New submission from Lovely Grace <lovelygrace26 at hotmail.com>:
The following code fails on the print command (see error message bellow
the code). I use windows and run the code under command prompt env.
import urllib.request
if __name__ == "__main__":
sock =
urllib.request.urlopen("http://docs.python.org/3.0/library/html.parser.html#html.parser.HTMLParser.handle_startendtag")
htmlSource = sock.read()
sock.close()
htmlSource = htmlSource.decode("utf-8", "strict")
print(htmlSource)
Error message:
Traceback (most recent call last):
File "parsehomeless.py", line 68, in <module>
print(htmlSource[0:281])
File "C:\Python30\lib\io.py", line 1494, in write
b = encoder.encode(s)
File "C:\Python30\lib\encodings\cp862.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2014' in
position 280: character maps to <undefined>
----------
components: Interpreter Core
messages: 82120
nosy: grace
severity: normal
status: open
title: Error printing UTF-8 decoded text
type: crash
versions: Python 3.1
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5263>
_______________________________________
More information about the New-bugs-announce
mailing list