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:
Claude Paroz 2012-08-16 21:03:11 +02:00
parent 37a894b48c
commit 5c79dd5865
1 changed files with 100 additions and 88 deletions

View File

@ -1,10 +1,22 @@
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
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): class HTMLParser(_html_parser.HTMLParser):
""" """
Patched version of stdlib's HTMLParser with patch from: Patched version of stdlib's HTMLParser with patch from: