MCPcopy Index your code
hub / github.com/RustPython/RustPython / parse_hex_char

Function parse_hex_char

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

Source from the content-addressed store, hash-verified

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

Callers 1

parse_basic_str_escapeFunction · 0.85

Calls 5

lenFunction · 0.85
TOMLDecodeErrorClass · 0.85
is_unicode_scalar_valueFunction · 0.85
chrFunction · 0.85
issupersetMethod · 0.45

Tested by

no test coverage detected