Lines 1-29
Link Here
|
1 |
commit b3a394d0837ff92919d35d01de9952b8809e802d |
|
|
2 |
Author: Helder Eijs <helderijs@gmail.com> |
3 |
Date: Wed Aug 28 07:52:19 2019 +0200 |
4 |
|
5 |
Force UTF-8 encoding when translating files |
6 |
|
7 |
diff --git ./setup.py ./setup.py |
8 |
index 9d88bc1e..1d70caad 100644 |
9 |
--- ./setup.py |
10 |
+++ ./setup.py |
11 |
@@ -222,14 +222,18 @@ def create_cryptodome_lib(): |
12 |
if full_file_name_src != "py.typed": |
13 |
continue |
14 |
|
15 |
- with open(full_file_name_dst, "rt") as fd: |
16 |
+ if sys.version_info[0] > 2: |
17 |
+ extra_param = { "encoding": "utf-8" } |
18 |
+ else: |
19 |
+ extra_param = {} |
20 |
+ with open(full_file_name_dst, "rt", **extra_param) as fd: |
21 |
content = (fd.read(). |
22 |
replace("Crypto.", "Cryptodome."). |
23 |
replace("Crypto ", "Cryptodome "). |
24 |
replace("'Crypto'", "'Cryptodome'"). |
25 |
replace('"Crypto"', '"Cryptodome"')) |
26 |
os.remove(full_file_name_dst) |
27 |
- with open(full_file_name_dst, "wt") as fd: |
28 |
+ with open(full_file_name_dst, "wt", **extra_param) as fd: |
29 |
fd.write(content) |