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

Datetime out of range exception should mention datetime_conversion feature

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 4.6
    • Affects Version/s: None
    • Component/s: None

      InvalidBSON exception for out of range datetimes should mention the datetime_conversion feature:

      >>> d = encode({'a': DatetimeMS(-2<<50)})
      >>> decode(d)
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "/Users/shane/git/mongo-python-driver/bson/__init__.py", line 1070, in decode
          return _bson_to_dict(data, opts)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^
      bson.errors.InvalidBSON: year -69387 is out of range
      

      Perhaps something like:

      bson.errors.InvalidBSON: year -69387 is out of range (Use CodecOptions(datetime_conversion=DATETIME_AUTO) or MongoClient(datetime_conversion='DATETIME_AUTO'))
      

            Assignee:
            jib.adegunloye@mongodb.com Jib Adegunloye
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: