Skip to content

gh-148518 fix index error in local part attribute#148522

Open
bitdancer wants to merge 5 commits intopython:mainfrom
bitdancer:fix_index_error_in_local_part_attribute_148518
Open

gh-148518 fix index error in local part attribute#148522
bitdancer wants to merge 5 commits intopython:mainfrom
bitdancer:fix_index_error_in_local_part_attribute_148518

Conversation

@bitdancer
Copy link
Copy Markdown
Member

@bitdancer bitdancer commented Apr 13, 2026

  • Add failing test.

  • Correct imperfect fix for variation of this bug.
    As part of fixing bpo-27931 code was introduced to get_bar_quoted_string
    that added an empty Terminal if the quoted string was empty. This isn't
    the best answer in terms of the parse tree, we really want the token
    list to be empty in that case. But having it be empty would result in
    local_part raising the index error. Which is the same bug we find if we
    try to parse an address consisting of a single dquote. So by fixing
    local_part to not raise in that case, we can have the bare_quoted_string
    code correctly return an empty token list for the empty string cases
    (two dquotes or a single dquote as the entire addrespec, at the end of a
    line).

    After this commit there will be two test failures instead of just one,
    and we'll fix both with the fix to local_part.

  • Fix the bug.

  • Add news item.
    I'm not sure this is worth a news item, though.

As part of fixing bpo-27931 code was introduced to get_bar_quoted_string
that added an empty Terminal if the quoted string was empty.  This isn't
the best answer in terms of the parse tree, we really want the token
list to be empty in that case.  But having it be empty would result in
local_part raising the index error.  Which is the same bug we find if we
try to parse an address consisting of a single dquote.  So by fixing
local_part to not raise in that case, we can have the bare_quoted_string
code correctly return an empty token list for the empty string cases
(two dquotes or a single dquote as the entire addrespec, at the end of a
line).

After this commit there will be two test failures instead of just one,
and we'll fix both with the fix to local_part.
I'm not sure this is worth a news item, though.
@bitdancer bitdancer requested a review from a team as a code owner April 13, 2026 20:02
@bitdancer bitdancer self-assigned this Apr 13, 2026
@bitdancer bitdancer changed the title fix index error in local part attribute 148518 gh-148518 fix index error in local part attribute Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant