diff options
author | ISSOtm <eldredhabert0@gmail.com> | 2018-06-03 16:54:29 +0200 |
---|---|---|
committer | ISSOtm <eldredhabert0@gmail.com> | 2018-06-03 16:57:02 +0200 |
commit | 3a7ac51071ad9f3ae277046c29d7482b56754d1d (patch) | |
tree | da4715657d4da214f57310bbcd49ca17b165492c /tools/disasm_coverage.py | |
parent | 20ac549a91c5e9249b1b04c16e65df2aefac1aae (diff) |
Make coverage script work on Python 2 again
I tested using both my Python 2 and Python 3, it worked for both.
Worked for me previously because Py3 is my default, not 2 :p
Diffstat (limited to 'tools/disasm_coverage.py')
-rw-r--r-- | tools/disasm_coverage.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/disasm_coverage.py b/tools/disasm_coverage.py index 6c1c030..39d1960 100644 --- a/tools/disasm_coverage.py +++ b/tools/disasm_coverage.py @@ -29,8 +29,13 @@ if __name__ == "__main__": rows_per_bank = bank_size // (width * bpp) r = MapReader() - with open(args.mapfile, 'r', encoding= "utf-8") as f: - l = f.readlines() + try: + with open(args.mapfile, 'r') as f: + l = f.readlines() + except UnicodeDecodeError: + # Python 3 seems to choke on the file's encoding, but the `encoding` keyword only works on Py3 + with open(args.mapfile, 'r', encoding= "utf-8") as f: + l = f.readlines() r.read_map_data(l) hit_data = [[0] * width for _ in range(height)] |