mirror of
https://github.com/python/cpython.git
synced 2025-09-22 08:23:36 +00:00
#17802: merge with 3.3.
This commit is contained in:
commit
f6ca26fbff
3 changed files with 18 additions and 0 deletions
|
@ -251,6 +251,7 @@ class HTMLParser(_markupbase.ParserBase):
|
||||||
if self.strict:
|
if self.strict:
|
||||||
self.error("EOF in middle of entity or char ref")
|
self.error("EOF in middle of entity or char ref")
|
||||||
else:
|
else:
|
||||||
|
k = match.end()
|
||||||
if k <= i:
|
if k <= i:
|
||||||
k = n
|
k = n
|
||||||
i = self.updatepos(i, i + 1)
|
i = self.updatepos(i, i + 1)
|
||||||
|
|
|
@ -535,6 +535,20 @@ class HTMLParserTolerantTestCase(HTMLParserStrictTestCase):
|
||||||
]
|
]
|
||||||
self._run_check(html, expected)
|
self._run_check(html, expected)
|
||||||
|
|
||||||
|
def test_EOF_in_charref(self):
|
||||||
|
# see #17802
|
||||||
|
# This test checks that the UnboundLocalError reported in the issue
|
||||||
|
# is not raised, however I'm not sure the returned values are correct.
|
||||||
|
# Maybe HTMLParser should use self.unescape for these
|
||||||
|
data = [
|
||||||
|
('a&', [('data', 'a&')]),
|
||||||
|
('a&b', [('data', 'ab')]),
|
||||||
|
('a&b ', [('data', 'a'), ('entityref', 'b'), ('data', ' ')]),
|
||||||
|
('a&b;', [('data', 'a'), ('entityref', 'b')]),
|
||||||
|
]
|
||||||
|
for html, expected in data:
|
||||||
|
self._run_check(html, expected)
|
||||||
|
|
||||||
def test_unescape_function(self):
|
def test_unescape_function(self):
|
||||||
p = self.get_collector()
|
p = self.get_collector()
|
||||||
self.assertEqual(p.unescape('&#bad;'),'&#bad;')
|
self.assertEqual(p.unescape('&#bad;'),'&#bad;')
|
||||||
|
|
|
@ -62,6 +62,9 @@ Library
|
||||||
|
|
||||||
- Issue #14679: add an __all__ (that contains only HTMLParser) to html.parser.
|
- Issue #14679: add an __all__ (that contains only HTMLParser) to html.parser.
|
||||||
|
|
||||||
|
- Issue #17802: Fix an UnboundLocalError in html.parser. Initial tests by
|
||||||
|
Thomas Barlow.
|
||||||
|
|
||||||
- Issue #17358: Modules loaded by imp.load_source() and load_compiled() (and by
|
- Issue #17358: Modules loaded by imp.load_source() and load_compiled() (and by
|
||||||
extention load_module()) now have a better chance of working when reloaded.
|
extention load_module()) now have a better chance of working when reloaded.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue