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>
This commit is contained in:
Brian Norris 2020-02-28 18:15:05 -08:00 committed by Josh Boyer
parent 7fa32bcc68
commit 94cb0a6837
No known key found for this signature in database
GPG Key ID: A31B6BD72486CFD6
1 changed files with 2 additions and 1 deletions

View File

@ -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: