Skip to content

Commit f369594

Browse files
committed
ci: name the encoding the check reads its sources in
Python opens a file with the platform's default encoding, which on the Windows runner is cp1252, and these sources are UTF-8: UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 90 A check that reads source files must say what they are encoded in, or it reports on the runner's locale rather than on the sources. The byte it stopped at is in a comment marker, so the check would have passed on a repository whose comments happened to be ASCII and failed on this one --- which is the least useful place for a difference to appear. Both reads name utf-8. Rehearsed locally under cp1252: 42 declared, 49 exported, none missing.
1 parent 6fda245 commit f369594

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,18 @@ jobs:
182182
run: |
183183
python3 - <<'PY'
184184
import glob, os, re, sys
185+
# ⚠️ THE ENCODING IS NAMED. Python opens a file with the platform's
186+
# default, which on this runner is cp1252, and these sources are UTF-8:
187+
#
188+
# UnicodeDecodeError: 'charmap' codec can't decode byte 0x90
189+
#
190+
# A check that reads source files must say what they are encoded in, or
191+
# it reports on the runner's locale.
185192
declared = set(re.findall(r'OKW_IMPORT\s+\w+\s+OKW_API\s+(\w+)\s*\(',
186-
open("src/win32.h").read()))
193+
open("src/win32.h", encoding="utf-8").read()))
187194
exported = set()
188195
for f in glob.glob("port/*.def"):
189-
body = open(f).read().split("EXPORTS", 1)
196+
body = open(f, encoding="utf-8").read().split("EXPORTS", 1)
190197
if len(body) < 2: continue
191198
exported |= {l.strip() for l in body[1].split("\n")
192199
if l.strip() and not l.lstrip().startswith(';')}

0 commit comments

Comments
 (0)