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'))