Browse Source

check_whence: python3/utf-8 support

WHENCE contains non-ASCII characters, so we should specify an encoding.
To get the encoding= arg in python2, we pull open from 'io' directly.

Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Josh Boyer <jwboyer@kernel.org>
main
Brian Norris 5 years ago committed by Josh Boyer
parent
commit
94cb0a6837
No known key found for this signature in database
GPG Key ID: A31B6BD72486CFD6
  1. 3
      check_whence.py

3
check_whence.py

@ -1,9 +1,10 @@ @@ -1,9 +1,10 @@
#!/usr/bin/python

import os, re, sys
from io import open

def list_whence():
with open('WHENCE') as whence:
with open('WHENCE', encoding='utf-8') as whence:
for line in whence:
match = re.match(r'(?:File|Source):\s*"(.*)"', line)
if match:

Loading…
Cancel
Save