title: pymongo error: bson.errors.InvalidBSON: 'utf8' codec can't decode byte 0xa1 in position 25: invalid start byte
body: <pre><code>tasks = list(self.collection.find().sort('_id',pymongo.DESCENDING).limit(1000))
  </code></pre>
  
  <p>I had a trouble when i use pymongo to solve a program.</p>
  
  <blockquote>
    <p>File "D:\Python27\lib\site-packages\pymongo-3.2.1-py2.7-win-amd64.egg\pymongo\cursor.py", line 1097, in next
      File "D:\Python27\lib\site-packages\pymongo-3.2.1-py2.7-win-amd64.egg\pymongo\cursor.py", line 1039, in _refresh
      File "D:\Python27\lib\site-packages\pymongo-3.2.1-py2.7-win-amd64.egg\pymongo\cursor.py", line 903, in __send_message
      File "D:\Python27\lib\site-packages\pymongo-3.2.1-py2.7-win-amd64.egg\pymongo\helpers.py", line 133, in _unpack_response
    bson.errors.InvalidBSON: 'utf8' codec can't decode byte 0xa1 in position 25: invalid start byte</p>
  </blockquote>
  
  <pre><code>tasks =self.collection.find().sort('_id',pymongo.DESCENDING).limit(1000)
  for task in tasks:  #If i use this way,it will also touch this problem
  
  task = self.collection.find_one()#It would do so,too
  </code></pre>
  
  <p>I step into pymongo to find out the reason.I find that the problem maybe cause by follow codes</p>
  
  <pre><code>    result = {"cursor_id": struct.unpack("&lt;q", response[4:12])[0],
            "starting_from": struct.unpack("&lt;i", response[12:16])[0],
            "number_returned": struct.unpack("&lt;i", response[16:20])[0],
            "data": bson.decode_all(response[20:], codec_options)}
  </code></pre>
  
  <p>in pymongo helper.py 133 line
  in bson.decode_all it show the problem cause by the failed decode about 'oid'，'oid' is the _id in mongo.Then I copy the document and make a same document with a new _id,then i success get the document .</p>
  
  <p>How can i solve the problem with the "for task in tasks:" style.</p>
  
  <p>pymongo version used: 3.2.1</p>