MCPcopy Index your code
hub / github.com/python/cpython / parse_hex_char

Function parse_hex_char

Lib/tomllib/_parser.py:583–593  ·  view source on GitHub ↗
(src: str, pos: Pos, hex_len: int)

Source from the content-addressed store, hash-verified

581
582
583def parse_hex_char(src: str, pos: Pos, hex_len: int) -> tuple[Pos, str]:
584 hex_str = src[pos : pos + hex_len]
585 if len(hex_str) != hex_len or not HEXDIGIT_CHARS.issuperset(hex_str):
586 raise TOMLDecodeError("Invalid hex value", src, pos)
587 pos += hex_len
588 hex_int = int(hex_str, 16)
589 if not is_unicode_scalar_value(hex_int):
590 raise TOMLDecodeError(
591 "Escaped character is not a Unicode scalar value", src, pos
592 )
593 return pos, chr(hex_int)
594
595
596def parse_literal_str(src: str, pos: Pos) -> tuple[Pos, str]:

Callers 1

parse_basic_str_escapeFunction · 0.85

Calls 3

TOMLDecodeErrorClass · 0.85
is_unicode_scalar_valueFunction · 0.85
issupersetMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…