https://github.com/python/cpython/commit/f9140e201c5b0372d0195ea3e289e8fa7761f78f commit: f9140e201c5b0372d0195ea3e289e8fa7761f78f branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ezio-melotti <[email protected]> date: 2026-04-27T22:30:00+08:00 summary:
[3.14] gh-82665 Mention that HTMLParser.handle_starttag value can be None (GH-134312) (#149037) gh-82665 Mention that HTMLParser.handle_starttag value can be None (GH-134312) * Specify boolean attribute behavior in parser * Tweak wording and example * Fix backticks --------- (cherry picked from commit 804c213c89366dd5ffa7feeb1bd4feccfee75b38) Co-authored-by: Micah Najacht <[email protected]> Co-authored-by: Ezio Melotti <[email protected]> Co-authored-by: Serhiy Storchaka <[email protected]> files: M Doc/library/html.parser.rst diff --git a/Doc/library/html.parser.rst b/Doc/library/html.parser.rst index 341a8337ba2ceb..11f851d4f6c4b7 100644 --- a/Doc/library/html.parser.rst +++ b/Doc/library/html.parser.rst @@ -141,7 +141,7 @@ implementations do nothing (except for :meth:`~HTMLParser.handle_startendtag`): argument is a list of ``(name, value)`` pairs containing the attributes found inside the tag's ``<>`` brackets. The *name* will be translated to lower case, and quotes in the *value* have been removed, and character and entity references - have been replaced. + have been replaced. For empty attributes, *value* is ``None``. For instance, for the tag ``<A HREF="https://www.cwi.nl/">``, this method would be called as ``handle_starttag('a', [('href', 'https://www.cwi.nl/')])``. @@ -317,6 +317,18 @@ without further parsing: Data : alert("<strong>hello! ☺</strong>"); End tag : script +Attribute names are converted to lowercase, quotes from attribute values removed, +and ``None`` is returned as *value* for empty attributes (such as ``checked``): + +.. doctest:: + + >>> parser.feed("<input TYPE='checkbox' checked required='' disabled=disabled>") + Start tag: input + attr: ('type', 'checkbox') + attr: ('checked', None) + attr: ('required', '') + attr: ('disabled', 'disabled') + Parsing comments: .. doctest:: _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
