MCPcopy
hub / github.com/tornadoweb/tornado / _get_version

Function _get_version

tornado/web.py:3648–3668  ·  view source on GitHub ↗
(value: bytes)

Source from the content-addressed store, hash-verified

3646
3647
3648def _get_version(value: bytes) -> int:
3649 # Figures out what version value is. Version 1 did not include an
3650 # explicit version field and started with arbitrary base64 data,
3651 # which makes this tricky.
3652 m = _signed_value_version_re.match(value)
3653 if m is None:
3654 version = 1
3655 else:
3656 try:
3657 version = int(m.group(1))
3658 if version > 999:
3659 # Certain payloads from the version-less v1 format may
3660 # be parsed as valid integers. Due to base64 padding
3661 # restrictions, this can only happen for numbers whose
3662 # length is a multiple of 4, so we can treat all
3663 # numbers up to 999 as versions, and for the rest we
3664 # fall back to v1 format.
3665 version = 1
3666 except ValueError:
3667 version = 1
3668 return version
3669
3670
3671def decode_signed_value(

Callers 2

decode_signed_valueFunction · 0.85

Calls 1

matchMethod · 0.45

Tested by

no test coverage detected