Skip to content

Commit 82377ec

Browse files
committed
Make Py3 code work on Py2 as well.
Everything works except the lxml treewalkers. That really needs rewritten.
1 parent 84b1710 commit 82377ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+157
-41
lines changed

html5lib/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import absolute_import, division, unicode_literals
2+
13
"""
24
HTML parsing library based on the WHATWG "HTML5"
35
specification. The parser is designed to be compatible with existing

html5lib/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import absolute_import, division, unicode_literals
2+
13
import string, gettext
24
_ = gettext.gettext
35

html5lib/filters/_base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import absolute_import, division, unicode_literals
2+
13

24
class Filter(object):
35
def __init__(self, source):

html5lib/filters/inject_meta_charset.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import absolute_import, division, unicode_literals
2+
13
from . import _base
24

35
class Filter(_base.Filter):

html5lib/filters/lint.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import absolute_import, division, unicode_literals
2+
13
from gettext import gettext
24
_ = gettext
35

html5lib/filters/optionaltags.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import absolute_import, division, unicode_literals
2+
13
from . import _base
24

35
class Filter(_base.Filter):

html5lib/filters/sanitizer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import absolute_import, division, unicode_literals
2+
13
from . import _base
24
from html5lib.sanitizer import HTMLSanitizerMixin
35

html5lib/filters/whitespace.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import absolute_import, division, unicode_literals
2+
13
import re
24

35
from . import _base

html5lib/html5parser.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from __future__ import absolute_import, division, unicode_literals
2+
from six import with_metaclass
3+
14
import sys
25
import types
36

@@ -444,7 +447,7 @@ def getMetaclass(use_metaclass, metaclass_func):
444447
else:
445448
return type
446449

447-
class Phase(object, metaclass=getMetaclass(debug, log)):
450+
class Phase(with_metaclass(getMetaclass(debug, log))):
448451
"""Base class for helper object that implements each phase of processing
449452
"""
450453

@@ -2686,7 +2689,7 @@ def impliedTagToken(name, type="EndTag", attributes = None,
26862689
selfClosing = False):
26872690
if attributes is None:
26882691
attributes = {}
2689-
return {"type":tokenTypes[type], "name":str(name), "data":attributes,
2692+
return {"type":tokenTypes[type], "name":name, "data":attributes,
26902693
"selfClosing":selfClosing}
26912694

26922695
class ParseError(Exception):

html5lib/ihatexml.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import absolute_import, division, unicode_literals
2+
13
import re
24
import warnings
35

0 commit comments

Comments
 (0)