A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/nedbat/coveragepy/issues/431 below:

Couldn't parse Python file with cp1252 encoding from xlwt · Issue #431 · nedbat/coveragepy · GitHub

Originally reported by Murat Knecht (Bitbucket: muratk, GitHub: muratk)

Coverage choked on a file from the xlwt library.

Couldn't parse 'venv/lib/python2.7/site-packages/xlwt/BIFFRecords.py' as Python source: ''charmap' codec can't decode byte 0x9d in position 68292: character maps to <undefined>' at line 0

To reproduce install these dependencies in a virtualenv env in the working directory:

argparse==1.2.1
coverage==4.0
wsgiref==0.1.2
xlwt==0.7.5

Then run this (which is the boiled down version of what coverage does, afaict:

from coverage import phystokens

f = open("./env/lib/python2.7/site-packages/xlwt/BIFFRecords.py", "rb")
raw = f.read()

enc = phystokens._source_encoding_py2(raw)
print("encoding: {}".format(enc))

uni = raw.decode(enc, "replace")
phystokens.compile_unicode(uni, "<string>", "exec")

When using compile directly on raw, it works.

Possibly related to #157.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4