Nicer error when packing a datetime without tzinfo (#466)

This commit is contained in:
Benjamin Egelund-Müller 2021-11-16 09:49:47 +01:00 committed by GitHub
parent cfa05d3fdc
commit e464cb44fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View file

@ -874,6 +874,10 @@ class Packer(object):
obj = self._default(obj)
default_used = 1
continue
if self._datetime and check(obj, _DateTime):
raise ValueError("Cannot serialize %r where tzinfo=None" % (obj,))
raise TypeError("Cannot serialize %r" % (obj,))
def pack(self, obj):