]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-42351: Avoid error when opening header with non-UTF8 encoding (GH-23279)
authorRonald Oussoren <ronaldoussoren@mac.com>
Sat, 14 Nov 2020 15:07:47 +0000 (16:07 +0100)
committerGitHub <noreply@github.com>
Sat, 14 Nov 2020 15:07:47 +0000 (16:07 +0100)
grep_headers_for() would error out when a header contained
text that cannot be interpreted as UTF-8.

setup.py

index c12b5f5042551a708ee47e261c330dc1bd54c5ad..91358af9b616b2bfc41462a4d99122125256bba0 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -241,7 +241,7 @@ def is_macosx_sdk_path(path):
 
 def grep_headers_for(function, headers):
     for header in headers:
-        with open(header, 'r') as f:
+        with open(header, 'r', errors='surrogateescape') as f:
             if function in f.read():
                 return True
     return False