Skip to content

Commit

Permalink
Revert "Ensure significant whitespace is not trimmed"
Browse files Browse the repository at this point in the history
This reverts commit c9f1143.
  • Loading branch information
martinblech committed Oct 16, 2024
1 parent 34759c3 commit 13068aa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tests/test_xmltodict.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ def test_skip_whitespace(self):
"""
self.assertEqual(
parse(xml),
{'root': {'emptya': " ",
{'root': {'emptya': None,
'emptyb': {'@attr': 'attrvalue'},
'value': 'hello'}})

def test_keep_whitespace(self):
xml = "<root> </root>"
self.assertEqual(parse(xml), dict(root=' '))
self.assertEqual(parse(xml), dict(root=None))
self.assertEqual(parse(xml, strip_whitespace=False),
dict(root=' '))

Expand Down
2 changes: 1 addition & 1 deletion xmltodict.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def endElement(self, full_name):
else self.cdata_separator.join(self.data))
item = self.item
self.item, self.data = self.stack.pop()
if self.strip_whitespace and data and item:
if self.strip_whitespace and data:
data = data.strip() or None
if data and self.force_cdata and item is None:
item = self.dict_constructor()
Expand Down

0 comments on commit 13068aa

Please sign in to comment.