"llen",
"vlen",
"bered",
+ "expl_bered",
)
def __init__(
self.offset, self.llen, self.vlen = _decoded
self.default = None
self.bered = False
+ self.expl_bered = False
@property
def ready(self): # pragma: no cover
)
try:
l, llen, v = len_decode(lv)
+ except LenIndefiniteForm as err:
+ if not ctx.get("bered", False):
+ raise err.__class__(
+ msg=err.msg,
+ klass=self.__class__,
+ decode_path=decode_path,
+ offset=offset,
+ )
+ llen, v = 1, lv[1:]
+ offset += tlen + llen
+ result = self._decode(
+ v,
+ offset=offset,
+ decode_path=decode_path,
+ ctx=ctx,
+ tag_only=tag_only,
+ )
+ if tag_only:
+ return
+ obj, tail = result
+ eoc_expected, tail = tail[:EOC_LEN], tail[EOC_LEN:]
+ if eoc_expected.tobytes() != EOC:
+ raise DecodeError(
+ msg="no EOC",
+ decode_path=decode_path,
+ offset=offset,
+ )
+ obj.vlen += EOC_LEN
+ obj.expl_bered = True
except DecodeError as err:
raise err.__class__(
msg=err.msg,
decode_path=decode_path,
offset=offset,
)
- if l > len(v):
- raise NotEnoughData(
- "encoded length is longer than data",
- klass=self.__class__,
+ else:
+ if l > len(v):
+ raise NotEnoughData(
+ "encoded length is longer than data",
+ klass=self.__class__,
+ decode_path=decode_path,
+ offset=offset,
+ )
+ result = self._decode(
+ v,
+ offset=offset + tlen + llen,
decode_path=decode_path,
- offset=offset,
+ ctx=ctx,
+ tag_only=tag_only,
)
- result = self._decode(
- v,
- offset=offset + tlen + llen,
- decode_path=decode_path,
- ctx=ctx,
- tag_only=tag_only,
- )
- if tag_only:
- return
- obj, tail = result
+ if tag_only:
+ return
+ obj, tail = result
return obj, (tail if leavemm else tail.tobytes())
@property
@property
def expl_llen(self):
+ if self.expl_bered:
+ return 1
return len(len_encode(self.tlvlen))
@property