Skip to content

TypeError: Cannot explicitly set an encoding with a unicode string #3

@SimonSapin

Description

@SimonSapin

I got this error when running the preprocessor. Removing encoding="utf8", in calls to html5lib.parse() "solved" it, but I have no idea if that was the right thing to do. The whole code could probably use a pass of looking at what’s supposed to by bytes and what’s supposed to be Unicode ;)

Traceback (most recent call last):
  File "/home/simon/.local/bin/css-preprocess", line 9, in <module>
    load_entry_point('css-preprocessor==0.0.0', 'console_scripts', 'css-preprocess')()
  File "/home/simon/projects/css/css-preprocessor/preprocess.py", line 67, in main
    doc.preprocess()
  File "/home/simon/projects/css/css-preprocessor/preprocess.py", line 986, in preprocess
    self.document = parseDocument(self.html)
  File "/home/simon/projects/css/css-preprocessor/preprocess.py", line 124, in parseDocument
    doc = html5lib.parse(str, treebuilder='lxml', encoding='utf-8', namespaceHTMLElements=False)
  File "/home/simon/.virtualenvs/css-preprocessor/lib/python2.7/site-packages/html5lib/html5parser.py", line 28, in parse
    return p.parse(doc, encoding=encoding)
  File "/home/simon/.virtualenvs/css-preprocessor/lib/python2.7/site-packages/html5lib/html5parser.py", line 224, in parse
    parseMeta=parseMeta, useChardet=useChardet)
  File "/home/simon/.virtualenvs/css-preprocessor/lib/python2.7/site-packages/html5lib/html5parser.py", line 88, in _parse
    parser=self, **kwargs)
  File "/home/simon/.virtualenvs/css-preprocessor/lib/python2.7/site-packages/html5lib/tokenizer.py", line 40, in __init__
    self.stream = HTMLInputStream(stream, encoding, parseMeta, useChardet)
  File "/home/simon/.virtualenvs/css-preprocessor/lib/python2.7/site-packages/html5lib/inputstream.py", line 128, in HTMLInputStream
    raise TypeError("Cannot explicitly set an encoding with a unicode string")
TypeError: Cannot explicitly set an encoding with a unicode string

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions