summaryrefslogtreecommitdiff
path: root/msgpack/fallback.py
diff options
context:
space:
mode:
authorInada Naoki <songofacandy@gmail.com>2019-12-05 18:29:15 +0900
committerGitHub <noreply@github.com>2019-12-05 18:29:15 +0900
commit641406902efaa8f22f4a7973d04c921a2a35a6be (patch)
tree386d7f59b87ce5b798b4a21ac55a3aabb77ddd68 /msgpack/fallback.py
parent2c6668941f72e3bcb797d096437683eca4e3caf5 (diff)
downloadmsgpack-python-641406902efaa8f22f4a7973d04c921a2a35a6be.tar.gz
Add Timestamp support (#382)
Diffstat (limited to 'msgpack/fallback.py')
-rw-r--r--msgpack/fallback.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/msgpack/fallback.py b/msgpack/fallback.py
index 9a48b71..55e66f5 100644
--- a/msgpack/fallback.py
+++ b/msgpack/fallback.py
@@ -66,7 +66,7 @@ from .exceptions import (
StackError,
)
-from . import ExtType
+from .ext import ExtType, Timestamp
EX_SKIP = 0
@@ -826,9 +826,13 @@ class Packer(object):
if self._use_float:
return self._buffer.write(struct.pack(">Bf", 0xca, obj))
return self._buffer.write(struct.pack(">Bd", 0xcb, obj))
- if check(obj, ExtType):
- code = obj.code
- data = obj.data
+ if check(obj, (ExtType, Timestamp)):
+ if check(obj, Timestamp):
+ code = -1
+ data = obj.to_bytes()
+ else:
+ code = obj.code
+ data = obj.data
assert isinstance(code, int)
assert isinstance(data, bytes)
L = len(data)