Fixed #18239 -- Subclassed HTMLParser only for selected Python versions
Only Python versions affected by http://bugs.python.org/issue670664 should patch HTMLParser. Thanks Raphaël Hertzog for the initial patch (for 1.4).
This commit is contained in:
parent
37a894b48c
commit
5c79dd5865
|
@ -1,11 +1,23 @@
|
||||||
from django.utils.six.moves import html_parser as _html_parser
|
from django.utils.six.moves import html_parser as _html_parser
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
tagfind = re.compile('([a-zA-Z][-.a-zA-Z0-9:_]*)(?:\s|/(?!>))*')
|
current_version = sys.version_info
|
||||||
|
|
||||||
|
use_workaround = (
|
||||||
|
(current_version < (2, 6, 8)) or
|
||||||
|
(current_version >= (2, 7) and current_version < (2, 7, 3)) or
|
||||||
|
(current_version >= (3, 0) and current_version < (3, 2, 3))
|
||||||
|
)
|
||||||
|
|
||||||
HTMLParseError = _html_parser.HTMLParseError
|
HTMLParseError = _html_parser.HTMLParseError
|
||||||
|
|
||||||
class HTMLParser(_html_parser.HTMLParser):
|
if not use_workaround:
|
||||||
|
HTMLParser = _html_parser.HTMLParser
|
||||||
|
else:
|
||||||
|
tagfind = re.compile('([a-zA-Z][-.a-zA-Z0-9:_]*)(?:\s|/(?!>))*')
|
||||||
|
|
||||||
|
class HTMLParser(_html_parser.HTMLParser):
|
||||||
"""
|
"""
|
||||||
Patched version of stdlib's HTMLParser with patch from:
|
Patched version of stdlib's HTMLParser with patch from:
|
||||||
http://bugs.python.org/issue670664
|
http://bugs.python.org/issue670664
|
||||||
|
|
Loading…
Reference in New Issue