Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

html.parser: check_for_whole_start_tag crashes with AssertionError on empty string #140877

Copy link
Copy link
@T90REAL

Description

@T90REAL
Issue body actions

Bug report

Bug description:

The html.parser.HTMLParser method check_for_whole_start_tag crashes with an AssertionError when its rawdata is an empty string.

from html.parser import HTMLParser

parser = HTMLParser()

parser.feed('')

result = parser.check_for_whole_start_tag(0)
Traceback (most recent call last):
  File "/data/src/test.py", line 11, in <module>
    result = parser.check_for_whole_start_tag(0)
  File "/home/hdd/miniconda3/lib/python3.13/html/parser.py", line 394, in check_for_whole_start_tag
    raise AssertionError("we should not get here!")
AssertionError: we should not get here!

I think the internal code should gracefully handle this None match by returning -1 instead if an AssertionError?

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.