mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.13] gh-118643: Fix AttributeError in the email module (GH-119099) (GH-119389)
Fix regression introduced in gh-100884: AttributeError when re-fold a long
address list.
Also fix more cases of incorrect encoding of the address separator in the
address list missed in gh-100884.
(cherry picked from commit 858b9e85fc
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
414346e56d
commit
6892b400dc
3 changed files with 24 additions and 5 deletions
|
@ -956,6 +956,7 @@ class _InvalidEwError(errors.HeaderParseError):
|
|||
DOT = ValueTerminal('.', 'dot')
|
||||
ListSeparator = ValueTerminal(',', 'list-separator')
|
||||
ListSeparator.as_ew_allowed = False
|
||||
ListSeparator.syntactic_break = False
|
||||
RouteComponentMarker = ValueTerminal('@', 'route-component-marker')
|
||||
|
||||
#
|
||||
|
@ -2844,7 +2845,9 @@ def _refold_parse_tree(parse_tree, *, policy):
|
|||
if not hasattr(part, 'encode'):
|
||||
# It's not a Terminal, do each piece individually.
|
||||
parts = list(part) + parts
|
||||
else:
|
||||
want_encoding = False
|
||||
continue
|
||||
elif part.as_ew_allowed:
|
||||
# It's a terminal, wrap it as an encoded word, possibly
|
||||
# combining it with previously encoded words if allowed.
|
||||
if (last_ew is not None and
|
||||
|
@ -2858,8 +2861,14 @@ def _refold_parse_tree(parse_tree, *, policy):
|
|||
# so clear it now.
|
||||
leading_whitespace = ''
|
||||
last_charset = charset
|
||||
want_encoding = False
|
||||
continue
|
||||
want_encoding = False
|
||||
continue
|
||||
else:
|
||||
# It's a terminal which should be kept non-encoded
|
||||
# (e.g. a ListSeparator).
|
||||
last_ew = None
|
||||
want_encoding = False
|
||||
# fall through
|
||||
|
||||
if len(tstr) <= maxlen - len(lines[-1]):
|
||||
lines[-1] += tstr
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue