Skip to content

Commit

Permalink
switch check_encoding.py to use isascii() function to attempt to fix …
Browse files Browse the repository at this point in the history
…GitHub CI failures
  • Loading branch information
grantfirl committed Nov 27, 2023
1 parent ade9c10 commit b40ee0f
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions tools/check_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
if suffix in SUFFICES:
with open(os.path.join(root, file)) as f:
contents = f.read()
try:
contents.decode('ascii')
except UnicodeDecodeError:
if not contents.isascii():
for line in contents.split('\n'):
try:
line.decode('ascii')
except UnicodeDecodeError:
raise Exception('Detected non-ascii characters in file {}, line: "{}"'.format(os.path.join(root, file), line))
if not line.isascii():
raise Exception('Detected non-ascii characters in file {}, line: "{}"'.format(os.path.join(root, file), line))

0 comments on commit b40ee0f

Please sign in to comment.