Commit 57d9ccc4 authored by Raphaël Hertzog's avatar Raphaël Hertzog Committed by Claude Paroz
Browse files

[1.4.x] Fixed #18239 -- Subclassed HTMLParser only for selected Python versions

Only Python versions affected by http://bugs.python.org/issue670664
should patch HTMLParser.
parent 3264894e
Loading
Loading
Loading
Loading
+97 −86
Original line number Diff line number Diff line
import HTMLParser as _HTMLParser
import re
import sys

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))
)

if not use_workaround:
    HTMLParser = _HTMLParser.HTMLParser
else:
    class HTMLParser(_HTMLParser.HTMLParser):
        """
        Patched version of stdlib's HTMLParser with patch from: