Skip to content

gh-156658: Only XML white space characters are treated as white space - #156659

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-156658-xml-whitespace
Open

gh-156658: Only XML white space characters are treated as white space#156659
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-156658-xml-whitespace

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Aug 30, 2026

Copy link
Copy Markdown
Member

XML defines white space as " \t\r\n" (XML 1.0, 2.3), but str.strip() also strips other characters, such as U+00A0. They are content, and were lost in:

  • ElementTree.indent(), which overwrote them with the indentation;
  • canonicalize(strip_text=True), which changed the canonical form;
  • xml.dom parsing with the whitespace-in-element-content feature turned off, which removed such text nodes from the document;
  • Text.isWhitespaceInElementContent, which reported them as ignorable white space.

… space

XML defines white space as " \t\r\n" (see XML 1.0, 2.3), but str.strip()
also strips other characters, such as U+00A0.  Such characters could be
lost in ElementTree.indent(), in canonicalize(strip_text=True), and when
parsing with the whitespace-in-element-content feature turned off.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant