aboutsummaryrefslogtreecommitdiff
path: root/security/py-pycryptodome/files/patch-setup.py
blob: 2c8ef65dccff09845ef9f9005135116efcf22ed5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
commit b3a394d0837ff92919d35d01de9952b8809e802d
Author: Helder Eijs <helderijs@gmail.com>
Date:   Wed Aug 28 07:52:19 2019 +0200

    Force UTF-8 encoding when translating files

diff --git ./setup.py ./setup.py
index 9d88bc1e..1d70caad 100644
--- ./setup.py
+++ ./setup.py
@@ -222,14 +222,18 @@ def create_cryptodome_lib():
                 if full_file_name_src != "py.typed":
                     continue

-            with open(full_file_name_dst, "rt") as fd:
+            if sys.version_info[0] > 2:
+                extra_param = { "encoding": "utf-8" }
+            else:
+                extra_param = {}
+            with open(full_file_name_dst, "rt", **extra_param) as fd:
                 content = (fd.read().
                            replace("Crypto.", "Cryptodome.").
                            replace("Crypto ", "Cryptodome ").
                            replace("'Crypto'", "'Cryptodome'").
                            replace('"Crypto"', '"Cryptodome"'))
             os.remove(full_file_name_dst)
-            with open(full_file_name_dst, "wt") as fd:
+            with open(full_file_name_dst, "wt", **extra_param) as fd:
                 fd.write(content)