#23144: merge with 3.5. · pythoncapi/cpython@564cf7b · GitHub
Skip to content

Commit 564cf7b

Browse files
committed
python#23144: merge with 3.5.
2 parents 56f6e76 + 20a2c64 commit 564cf7b

3 files changed

Lines changed: 26 additions & 5 deletions

File tree

Lib/html/parser.py

Lines changed: 9 additions & 1 deletion

Lib/test/test_htmlparser.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ def handle_starttag(self, tag, attrs):
7272

7373
class EventCollectorCharrefs(EventCollector):
7474

75-
def get_events(self):
76-
return self.events
77-
7875
def handle_charref(self, data):
7976
self.fail('This should never be called with convert_charrefs=True')
8077

@@ -633,6 +630,18 @@ def test_broken_condcoms(self):
633630
]
634631
self._run_check(html, expected)
635632

633+
def test_convert_charrefs_dropped_text(self):
634+
# #23144: make sure that all the events are triggered when
635+
# convert_charrefs is True, even if we don't call .close()
636+
parser = EventCollector(convert_charrefs=True)
637+
# before the fix, bar & baz was missing
638+
parser.feed("foo <a>link</a> bar &amp; baz")
639+
self.assertEqual(
640+
parser.get_events(),
641+
[('data', 'foo '), ('starttag', 'a', []), ('data', 'link'),
642+
('endtag', 'a'), ('data', ' bar & baz')]
643+
)
644+
636645

637646
class AttributesTestCase(TestCaseBase):
638647

Misc/NEWS

Lines changed: 5 additions & 1 deletion

0 commit comments

Comments
 (0)