Skip to content

Commit d2d59ee

Browse files
committed
Comments from PR review, improve phrasing
1 parent 7cba42f commit d2d59ee

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

Lib/email/_header_value_parser.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2404,13 +2404,12 @@ def get_section(value):
24042404
value))
24052405
section.append(ValueTerminal('*', 'section-marker'))
24062406
value = value[1:]
2407-
# We don't use str.isdigit because only 0-9 are accepted, not super-script
2408-
# and other types of digits.
2409-
if not value or not '0' <= value[0] <= '9':
2407+
# We don't use str.isdigit because only ASCII digits are allowed.
2408+
if not value or not ('0' <= value[0] <= '9'):
24102409
raise errors.HeaderParseError("Expected section number but "
24112410
"found {}".format(value))
24122411
digits = ''
2413-
while value and '0' <= value[0] <= '9':
2412+
while value and ('0' <= value[0] <= '9'):
24142413
digits += value[0]
24152414
value = value[1:]
24162415
if digits[0] == '0' and digits != '0':

Lib/test/test_email/test__header_value_parser.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2983,8 +2983,7 @@ def mime_parameters_as_value(self,
29832983
[('r', '"')],
29842984
[errors.InvalidHeaderDefect]*2),
29852985

2986-
# gh-87112: Unicode super-script digits (and others) are not allowed
2987-
# as section numbers.
2986+
# gh-87112: Only ASCII digits can be section numbers.
29882987
'non_allowed_digits': (
29892988
'foo*0=bar; foo*²=baz',
29902989
' foo="bar"',

0 commit comments

Comments
 (0)