UnicodeDecodeError
Python 3.0: G:\cgi\python\python.exe
Thu Jan 15 22:29:09 2009

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.

 G:\webserver\xampp\cgi-bin\testupload.py in ()
  109 print ("encoding:",encoding,"<br>")
  110 stdin = open(sys.stdin.fileno(), 'r', encoding=encoding)
  111 opsform = cgi.FieldStorage(stdin)
  112   
  113 
opsform undefined, cgi = <module 'cgi' from 'G:\cgi\python\lib\cgi.py'>, cgi.FieldStorage = <class 'cgi.FieldStorage'>, stdin = <io.TextIOWrapper object at 0x00DD62D0>
 G:\cgi\python\lib\cgi.py in __init__(self=FieldStorage(None, None, []), fp=<io.TextIOWrapper object at 0x00DD62D0>, headers={'content-length': '177253', 'content-type': 'multipart/form-data; boundary=---------------------------7d9ea9302f4'}, outerboundary='', environ=<os._Environ object at 0x00C90C10>, keep_blank_values=0, strict_parsing=0)
  477             self.read_urlencoded()
  478         elif ctype[:10] == 'multipart/':
  479             self.read_multi(environ, keep_blank_values, strict_parsing)
  480         else:
  481             self.read_single()
self = FieldStorage(None, None, []), self.read_multi = <bound method FieldStorage.read_multi of FieldStorage(None, None, [])>, environ = <os._Environ object at 0x00C90C10>, keep_blank_values = 0, strict_parsing = 0
 G:\cgi\python\lib\cgi.py in read_multi(self=FieldStorage(None, None, []), environ=<os._Environ object at 0x00C90C10>, keep_blank_values=0, strict_parsing=0)
  597         # Create bogus content-type header for proper multipart parsing
  598         parser.feed('Content-Type: %s; boundary=%s\r\n\r\n' % (self.type, ib))
  599         parser.feed(self.fp.read())
  600         full_msg = parser.close()
  601         # Get subparts
parser = <email.feedparser.FeedParser object at 0x00DD6310>, parser.feed = <bound method FeedParser.feed of <email.feedparser.FeedParser object at 0x00DD6310>>, self = FieldStorage(None, None, []), self.fp = <io.TextIOWrapper object at 0x00DD62D0>, self.fp.read = <bound method TextIOWrapper.read of <io.TextIOWrapper object at 0x00DD62D0>>
 G:\cgi\python\lib\io.py in read(self=<io.TextIOWrapper object at 0x00DD62D0>, n=-1)
 1722             # Read everything.
 1723             result = (self._get_decoded_chars() +
 1724                       decoder.decode(self.buffer.read(), final=True))
 1725             self._set_decoded_chars('')
 1726             self._snapshot = None
decoder = <io.IncrementalNewlineDecoder object at 0x00DD67B0>, decoder.decode = <bound method IncrementalNewlineDecoder.decode o....IncrementalNewlineDecoder object at 0x00DD67B0>>, self = <io.TextIOWrapper object at 0x00DD62D0>, self.buffer = <io.BufferedReader object at 0x00DD6250>, self.buffer.read = <bound method BufferedReader.read of <io.BufferedReader object at 0x00DD6250>>, final undefined
 G:\cgi\python\lib\io.py in decode(self=<io.IncrementalNewlineDecoder object at 0x00DD67B0>, input=b'-----------------------------7d9ea9302f4\nCont...\x0e\x0f\x0c\x10\x17\x14\x18\x18\x17\x14\x16\x16', final=True)
 1293             input = self.buffer + input
 1294 
 1295         output = self.decoder.decode(input, final=final)
 1296 
 1297         # retain last \r even when not translating data:
output undefined, self = <io.IncrementalNewlineDecoder object at 0x00DD67B0>, self.decoder = <encodings.gbk.IncrementalDecoder object at 0x00DB8B70>, self.decoder.decode = <built-in method decode of IncrementalDecoder object at 0x00DB8B70>, input = b'-----------------------------7d9ea9302f4\nCont...\x0e\x0f\x0c\x10\x17\x14\x18\x18\x17\x14\x16\x16', final = True

UnicodeDecodeError: 'gbk' codec can't decode bytes in position 226-227: illegal multibyte sequence
      args = ('gbk', b'-----------------------------7d9ea9302f4\nCont...\x0e\x0f\x0c\x10\x17\x14\x18\x18\x17\x14\x16\x16', 226, 228, 'illegal multibyte sequence')
      encoding = 'gbk'
      end = 228
      object = b'-----------------------------7d9ea9302f4\nCont...\x0e\x0f\x0c\x10\x17\x14\x18\x18\x17\x14\x16\x16'
      reason = 'illegal multibyte sequence'
      start = 226
      with_traceback = <built-in method with_traceback of UnicodeDecodeError object at 0x00DB8B30>