From 13068aa9aecccc502eb57aec010ce7258941252f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Blech?= <78768+martinblech@users.noreply.github.com> Date: Tue, 15 Oct 2024 23:02:51 -0700 Subject: [PATCH] Revert "Ensure significant whitespace is not trimmed" This reverts commit c9f1143694c52666818715e865a56ffc46d9232e. --- tests/test_xmltodict.py | 4 ++-- xmltodict.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_xmltodict.py b/tests/test_xmltodict.py index 037771e..7dd22b5 100644 --- a/tests/test_xmltodict.py +++ b/tests/test_xmltodict.py @@ -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 = " " - self.assertEqual(parse(xml), dict(root=' ')) + self.assertEqual(parse(xml), dict(root=None)) self.assertEqual(parse(xml, strip_whitespace=False), dict(root=' ')) diff --git a/xmltodict.py b/xmltodict.py index cca2dae..b903798 100755 --- a/xmltodict.py +++ b/xmltodict.py @@ -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()