Fix HTMLParser related deprecation warnings in Py3.4

This commit is contained in:
Deniz Turgut 2014-06-11 15:58:06 -04:00
commit ce8574aff4
2 changed files with 10 additions and 11 deletions

View file

@ -21,10 +21,7 @@ try:
from html import escape
except ImportError:
from cgi import escape
try:
from html.parser import HTMLParser
except ImportError:
from HTMLParser import HTMLParser
from six.moves.html_parser import HTMLParser
from pelican import signals
from pelican.contents import Page, Category, Tag, Author
@ -43,7 +40,6 @@ METADATA_PROCESSORS = {
logger = logging.getLogger(__name__)
class BaseReader(object):
"""Base class to read files.
@ -231,7 +227,11 @@ class HTMLReader(BaseReader):
class _HTMLParser(HTMLParser):
def __init__(self, settings, filename):
HTMLParser.__init__(self)
try:
# Python 3.4+
HTMLParser.__init__(self, convert_charrefs=False)
except TypeError:
HTMLParser.__init__(self)
self.body = ''
self.metadata = {}
self.settings = settings