Skip to content

Commit b15c404

Browse files
committed
Comments from PR review, remove inner function
1 parent 75636a5 commit b15c404

2 files changed

Lines changed: 4 additions & 8 deletions

File tree

Lib/email/_header_value_parser.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,22 +2398,19 @@ def get_section(value):
23982398
The caller should already have dealt with leading CFWS.
23992399
24002400
"""
2401-
def is_allowed_digit(c):
2402-
# We don't use str.isdigit because only 0-9 are accepted, not
2403-
# super-script and other types of digits.
2404-
return c in {'0','1','2','3','4','5','6','7','8','9'}
2405-
24062401
section = Section()
24072402
if not value or value[0] != '*':
24082403
raise errors.HeaderParseError("Expected section but found {}".format(
24092404
value))
24102405
section.append(ValueTerminal('*', 'section-marker'))
24112406
value = value[1:]
2412-
if not value or not is_allowed_digit(value[0]):
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':
24132410
raise errors.HeaderParseError("Expected section number but "
24142411
"found {}".format(value))
24152412
digits = ''
2416-
while value and is_allowed_digit(value[0]):
2413+
while value and '0' <= value[0] <= '9':
24172414
digits += value[0]
24182415
value = value[1:]
24192416
if digits[0] == '0' and digits != '0':

Lib/test/test_email/test__header_value_parser.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2991,7 +2991,6 @@ def mime_parameters_as_value(self,
29912991
'foo*0=bar; foo*²=baz',
29922992
[('foo', 'bar')],
29932993
[errors.InvalidHeaderDefect]),
2994-
29952994
}
29962995

29972996
@parameterize

0 commit comments

Comments
 (0)