bpo-42351: Avoid error when opening header with non-UTF8 encoding (GH-23279)

grep_headers_for() would error out when a header contained
text that cannot be interpreted as UTF-8.
This commit is contained in:
Ronald Oussoren 2020-11-14 16:07:47 +01:00 committed by GitHub
parent 2b39da4997
commit 7a27c7ed4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -241,7 +241,7 @@ def is_macosx_sdk_path(path):
def grep_headers_for(function, headers): def grep_headers_for(function, headers):
for header in headers: for header in headers:
with open(header, 'r') as f: with open(header, 'r', errors='surrogateescape') as f:
if function in f.read(): if function in f.read():
return True return True
return False return False