classification
Title: Error printing UTF-8 decoded text
Type: crash Stage:
Components: Interpreter Core Versions: Python 3.1
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: grace
Priority: normal Keywords:

Created on 2009-02-14 21:33 by grace, last changed 2009-02-14 22:21 by benjamin.peterson. This issue is now closed.

Messages (2)
msg82120 - (view) Author: Lovely Grace (grace) Date: 2009-02-14 21:33
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>
msg82121 - (view) Author: Lovely Grace (grace) Date: 2009-02-14 21:40
Sorry guys, my goof:

http://wiki.python.org/moin/PrintFails
History
Date User Action Args
2009-02-14 22:21:26benjamin.petersonsetstatus: open -> closed
resolution: not a bug
2009-02-14 21:40:12gracesetmessages: + msg82121
2009-02-14 21:33:34gracecreate