summaryrefslogtreecommitdiff
path: root/msgpack/fallback.py
diff options
context:
space:
mode:
authorBenjamin Egelund-Müller <b@egelund-muller.com>2021-11-16 09:49:47 +0100
committerGitHub <noreply@github.com>2021-11-16 17:49:47 +0900
commite464cb44fa3af5ad3ecd83f9c045b16981d01bb2 (patch)
tree060cdcdc6d87d0e3763daa52cf40c4d4675a3fb3 /msgpack/fallback.py
parentcfa05d3fdc6290b4847e4781a06ac0668ea9dc18 (diff)
downloadmsgpack-python-e464cb44fa3af5ad3ecd83f9c045b16981d01bb2.tar.gz
Nicer error when packing a datetime without tzinfo (#466)
Diffstat (limited to 'msgpack/fallback.py')
-rw-r--r--msgpack/fallback.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/msgpack/fallback.py b/msgpack/fallback.py
index 4540875..b27acb2 100644
--- a/msgpack/fallback.py
+++ b/msgpack/fallback.py
@@ -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):