Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1128

unicode decode error when creating index

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.3
    • Fix Version/s: 3.4
    • Component/s: None
    • Labels:
    • Environment:
      Python 2.7.10
      Python 3.5.1

      Description

      When creating a index in Mongo shell, I got the correct exception:

      `> db.case_detail.createIndex(

      {'案号': 1}

      ,

      {background: true}

      )
      {
      "createdCollectionAutomatically" : false,
      "numIndexesBefore" : 9,
      "errmsg" : "exception: Btree::insert: key too large to index, failing guangdong_courts.case_detail.$案号_1 5360 { : \"(2015)佛明法民一初字第653号当事人:原告:杨瑞芳,被告:李永清\n案由:民间借贷纠纷\n开庭时间:2015-11-3 15:00\n开庭地��...\" }",
      "code" : 17280,
      "ok" : 0
      }` ,

      But when I use pymongo, I got this error:

      `---------------------------------------------------------------------------
      UnicodeDecodeError Traceback (most recent call last)
      /mongo-python-driver/bson/_init_.py in decode_all(data, codec_options)
      806 obj_end,
      --> 807 codec_options))
      808 position += obj_size

      /mongo-python-driver/bson/_init_.py in _elements_to_dict(data, position, obj_end, opts)
      343 result = opts.document_class()
      --> 344 for key, value in _iterate_elements(data, position, obj_end, opts):
      345 result[key] = value

      /mongo-python-driver/bson/_init_.py in _iterate_elements(data, position, obj_end, opts)
      336 while position < end:
      --> 337 (key, value, position) = _element_to_dict(data, position, obj_end, opts)
      338 yield key, value

      /mongo-python-driver/bson/_init_.py in _element_to_dict(data, position, obj_end, opts)
      325 obj_end, opts,
      --> 326 element_name)
      327 except KeyError:

      /mongo-python-driver/bson/_init_.py in _get_string(data, position, obj_end, opts, dummy)
      131 return _utf_8_decode(data[position:end],
      --> 132 opts.unicode_decode_error_handler, True)[0], end + 1
      133

      UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 255-256: invalid continuation byte`

        Attachments

          Activity

            People

            Assignee:
            luke.lovett Luke Lovett
            Reporter:
            tylderen tylderen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: