Skip to content

Commit

Permalink
Fix the way *_encoding properties are handled
Browse files Browse the repository at this point in the history
See #334
  • Loading branch information
liZe committed Jul 15, 2016
1 parent 5471ac9 commit da2e3b3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions weasyprint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,15 @@ def __init__(self, guess=None, filename=None, url=None, file_obj=None,
if source_type == 'tree':
result = source
else:
if not encoding:
encoding = protocol_encoding
if isinstance(source, unicode):
encoding = None
result = html5lib.parse(
source, treebuilder='lxml', likely_encoding=encoding,
namespaceHTMLElements=False)
result = html5lib.parse(
source, treebuilder='lxml',
namespaceHTMLElements=False)
else:
result = html5lib.parse(
source, treebuilder='lxml', override_encoding=encoding,
transport_encoding=protocol_encoding,
namespaceHTMLElements=False)
assert result
base_url = find_base_url(result, base_url)
if hasattr(result, 'getroot'):
Expand Down

0 comments on commit da2e3b3

Please sign in to comment.