Calling pysolr.Solr.add with a dict containing a datetime object causes the following stack trace:
File "<>/.local/lib/python3.7/site-packages/pysolr.py", line 1018, in add
m = json.dumps(message).encode("utf-8")
File "/usr/lib/python3.7/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python3.7/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.7/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python3.7/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type datetime is not JSON serializable
I believe this change to be the breaking change.
Before this change the datetime object could propagate via self._build_doc to self._from_python where the first check would have converted it to a string.
I have
Expected behaviour
No exception
Actual behaviour
TypeError: Object of type datetime is not JSON serializable
Configuration
- Operating system version: debian 10
- Search engine version: 8.5.1
- Python version: 3.7
- pysolr version: 3.9.0
Calling
pysolr.Solr.addwith a dict containing adatetimeobject causes the following stack trace:I believe this change to be the breaking change.
Before this change the datetime object could propagate via
self._build_doctoself._from_pythonwhere the first check would have converted it to a string.I have
Expected behaviour
No exception
Actual behaviour
TypeError: Object of type datetime is not JSON serializableConfiguration