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

Better error message when C extension raises InvalidStringData

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.6
    • Affects Version/s: 2.5.2
    • Component/s: None
    • None

      Prompted by Stack Overflow:

      http://stackoverflow.com/questions/16572580/how-can-i-find-which-value-caused-a-bson-errors-invalidstringdata

      InvalidStringData includes a repr of the invalid string when raised by the Python BSON implementation, but not when raised by the C implementation.

      >>> bad = {}
      >>> bad['zzz'] = '0\x82\x05\x17'
      >>> try:
      ...   MongoClient().test.test.insert(bad)
      ... except bson.errors.InvalidStringData as isd:
      ...   my_error = isd
      ...
      >>> my_error
      InvalidStringData('strings in documents must be valid UTF-8',)
      

            Assignee:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Reporter:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: