4141)
4242KEY_INITIAL_CHARS : Final = BARE_KEY_CHARS | frozenset ("\" '" )
4343HEXDIGIT_CHARS : Final = frozenset ("abcdef" "ABCDEF" "0123456789" )
44- _DECDIGIT_CHARS : Final = frozenset ("0123456789" )
45- _NUMBER_INITIAL_CHARS : Final = _DECDIGIT_CHARS | frozenset ("+-" )
46- _NUMBER_END_CHARS : Final = frozenset (",]}" ) | TOML_WS_AND_NEWLINE
44+ DECDIGIT_CHARS : Final = frozenset ("0123456789" )
45+ NUMBER_INITIAL_CHARS : Final = DECDIGIT_CHARS | frozenset ("+-" )
46+ NUMBER_END_CHARS : Final = frozenset (",]}" ) | TOML_WS_AND_NEWLINE
4747
4848BASIC_STR_ESCAPE_REPLACEMENTS : Final = frozendict ( # type: ignore[name-defined]
4949 {
@@ -668,17 +668,18 @@ def parse_basic_str(src: str, pos: Pos, *, multiline: bool) -> tuple[Pos, str]:
668668 pos += 1
669669
670670
671- def _parse_simple_number (
671+ # Sub-set of RE_NUMBER: only support decimal integer without "_" separator
672+ def parse_simple_number (
672673 src : str , pos : Pos
673674) -> None | tuple [Pos , int ]:
674675 start = pos
675676 end = len (src )
676- end_chars = _NUMBER_END_CHARS
677+ end_chars = NUMBER_END_CHARS
677678 if src [pos ] in '+-' :
678679 pos += 1
679680 if pos >= end :
680681 return None
681- if src [pos ] not in _DECDIGIT_CHARS :
682+ if src [pos ] not in DECDIGIT_CHARS :
682683 return None
683684
684685 if src [pos ] == '0' :
@@ -687,7 +688,7 @@ def _parse_simple_number(
687688 return None
688689 return pos , 0
689690
690- while src [pos ] in _DECDIGIT_CHARS :
691+ while src [pos ] in DECDIGIT_CHARS :
691692 pos += 1
692693 if pos >= end :
693694 break
@@ -737,8 +738,8 @@ def parse_value(
737738
738739 # First try a simple number parser which defers import tomllib._re
739740 # to speed up tomllib import time
740- if char in _NUMBER_INITIAL_CHARS :
741- res = _parse_simple_number (src , pos )
741+ if char in NUMBER_INITIAL_CHARS :
742+ res = parse_simple_number (src , pos )
742743 if res is not None :
743744 return res
744745
0 commit comments