Skip to content

Commit ae65cd6

Browse files
committed
Pass the encoding parameter to the parse method in all cases
Pass the encoding parameter to the parse method even when using Python 3, since there are some cases when you need to specify it. Use None as the default encoding value, respecting html5lib's encoding detection logic.
1 parent 3adb698 commit ae65cd6

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

microdata.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,14 @@
1111
import simplejson as json
1212

1313

14-
def get_items(location, encoding='UTF-8'):
14+
def get_items(location, encoding=None):
1515
"""
1616
Pass in a string or file-like object and get a list of Items present in the
1717
HTML document.
1818
"""
1919
dom_builder = html5lib.treebuilders.getTreeBuilder("dom")
2020
parser = html5lib.HTMLParser(tree=dom_builder)
21-
22-
if (sys.version_info.major == 3):
23-
tree = parser.parse(location)
24-
else:
25-
tree = parser.parse(location, encoding=encoding)
26-
21+
tree = parser.parse(location, encoding=encoding)
2722
return _find_items(tree)
2823

2924

0 commit comments

Comments
 (0)