1
0

use explicit utf-8 encoding when opening files in text mode

This commit is contained in:
SomberNight
2018-03-23 21:47:51 +01:00
parent 382f69edd9
commit 9b7536e75c
11 changed files with 25 additions and 25 deletions

View File

@@ -172,7 +172,7 @@ class TcpConnection(threading.Thread, util.PrintError):
# workaround android bug
cert = re.sub("([^\n])-----END CERTIFICATE-----","\\1\n-----END CERTIFICATE-----",cert)
temporary_path = cert_path + '.temp'
with open(temporary_path,"w") as f:
with open(temporary_path, "w", encoding='utf-8') as f:
f.write(cert)
f.flush()
os.fsync(f.fileno())
@@ -201,7 +201,7 @@ class TcpConnection(threading.Thread, util.PrintError):
os.unlink(rej)
os.rename(temporary_path, rej)
else:
with open(cert_path) as f:
with open(cert_path, encoding='utf-8') as f:
cert = f.read()
try:
b = pem.dePem(cert, 'CERTIFICATE')
@@ -398,7 +398,7 @@ def test_certificates():
certs = os.listdir(mydir)
for c in certs:
p = os.path.join(mydir,c)
with open(p) as f:
with open(p, encoding='utf-8') as f:
cert = f.read()
check_cert(c, cert)