diff options
author | jfolz <theriddling@gmail.com> | 2017-04-29 19:33:20 +0200 |
---|---|---|
committer | INADA Naoki <methane@users.noreply.github.com> | 2017-04-30 02:33:20 +0900 |
commit | a8d9162ca6cff6101c1f6b9547e94749c6acae96 (patch) | |
tree | 151a0d023a43cb93e586a3a377d5c2e82bdced03 /msgpack/fallback.py | |
parent | 3388e4a6ee6adea56789d97cc05ed610a4e5b4fc (diff) | |
download | msgpack-python-a8d9162ca6cff6101c1f6b9547e94749c6acae96.tar.gz |
Unpacker: add tell() (#227)
Diffstat (limited to 'msgpack/fallback.py')
-rw-r--r-- | msgpack/fallback.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/msgpack/fallback.py b/msgpack/fallback.py index d2eb9f4..508fd06 100644 --- a/msgpack/fallback.py +++ b/msgpack/fallback.py @@ -244,6 +244,7 @@ class Unpacker(object): self._max_array_len = max_array_len self._max_map_len = max_map_len self._max_ext_len = max_ext_len + self._stream_offset = 0 if list_hook is not None and not callable(list_hook): raise TypeError('`list_hook` is not callable') @@ -266,6 +267,7 @@ class Unpacker(object): def _consume(self): """ Gets rid of the used parts of the buffer. """ + self._stream_offset += self._buff_i - self._buf_checkpoint self._buf_checkpoint = self._buff_i def _got_extradata(self): @@ -629,6 +631,9 @@ class Unpacker(object): self._consume() return ret + def tell(self): + return self._stream_offset + class Packer(object): """ |