import collections
+import io
TAG_NULL = 0x00
TAG_TRUE = 0x01
def _make_tag_only_parser(tag, value):
def parser(b):
- return TaggedObject(tag = tag, instance = value), b
+ return TaggedObject(tag = tag, instance = value)
return parser
}
def deserialize(b):
- result, remainder = _TAGS_TO_PARSERS[b[0]](b[1:])
+ if isinstance(b, bytes):
+ b = io.BytesIO(b)
+
+ tag = b.read(1)[0]
+
+ result = _TAGS_TO_PARSERS[tag](b)
+
+ remainder = b.read()
if len(remainder) == 0:
return result