diff options
author | INADA Naoki <methane@users.noreply.github.com> | 2018-01-11 23:50:41 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-11 23:50:41 +0900 |
commit | d9ec8fc905fc9ed37c86700f794adeb883b4f5ea (patch) | |
tree | c6e04f096bf0f6adc0c8632a98d0a05019fc7559 /msgpack/fallback.py | |
parent | 60ef3879d792ec92480cf9d6d610951657c2e8c7 (diff) | |
download | msgpack-python-d9ec8fc905fc9ed37c86700f794adeb883b4f5ea.tar.gz |
Packer.pack() reset buffer on exception (#274)
fixes #210
Diffstat (limited to 'msgpack/fallback.py')
-rw-r--r-- | msgpack/fallback.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/msgpack/fallback.py b/msgpack/fallback.py index d95f621..675ee8a 100644 --- a/msgpack/fallback.py +++ b/msgpack/fallback.py @@ -848,7 +848,11 @@ class Packer(object): raise TypeError("Cannot serialize %r" % (obj, )) def pack(self, obj): - self._pack(obj) + try: + self._pack(obj) + except: + self._buffer = StringIO() # force reset + raise ret = self._buffer.getvalue() if self._autoreset: self._buffer = StringIO() |