Skip to content

MismatchedTokenError when empty tuple has commented out line #789

Closed as not planned

Description

@apmorton

Given code like:

a = (
    # foo,
)

get_patched_ast will incorrectly scan past the empty tuple and cause MismatchedTokenError.

The following test case will blow up in _consume_pattern because it does not match the pattern

    def test_empty_tuple_node4(self):
        source = "a = (\n# foo,\n)"
        ast_frag = patchedast.get_patched_ast(source, True)
        checker = _ResultChecker(self, ast_frag)
        checker.check_children("Tuple", ["()"])

Activity

  1. added
    bugUnexpected or incorrect user-visible behavior
    on May 1, 2024
  2. lieryan commented on Nov 8, 2026

    @lieryan
    Member

    Closing as per comment on the #790.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUnexpected or incorrect user-visible behavior

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions