From e839539a6ec0ac95f2472b1380ab18d8e526d456 Mon Sep 17 00:00:00 2001 From: Qi Zhao Date: Tue, 26 Mar 2024 14:17:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20read=5Ftext=20encoding=20?= =?UTF-8?q?in=20Windows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyencrypt/encrypt.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pyencrypt/encrypt.py b/pyencrypt/encrypt.py index 9d4dc28..466d2df 100644 --- a/pyencrypt/encrypt.py +++ b/pyencrypt/encrypt.py @@ -57,13 +57,13 @@ def generate_so_file(cipher_key: str, d: int, n: int, base_dir: Optional[Path] = need_import_files = ['ntt.py', 'aes.py', 'decrypt.py', 'license.py'] for file in need_import_files: file_path = path / file - decrypt_source_ls.append(REMOVE_SELF_IMPORT.sub('', file_path.read_text())) + decrypt_source_ls.append(REMOVE_SELF_IMPORT.sub('', file_path.read_text(encoding="utf-8"))) - loader_source_path = path / 'loader.py' - loader_source = REMOVE_SELF_IMPORT.sub('', loader_source_path.read_text()).replace( - "__private_key = ''", f"__private_key = '{private_key}'", 1 - ).replace("__cipher_key = ''", f"__cipher_key = '{cipher_key}'", 1).replace( - 'license = None', f'license = {license}', 1 + loader_source = ( + REMOVE_SELF_IMPORT.sub("", loader_source_path.read_text(encoding="utf-8")) + .replace("__private_key = ''", f"__private_key = '{private_key}'", 1) + .replace("__cipher_key = ''", f"__cipher_key = '{cipher_key}'", 1) + .replace("license = None", f"license = {license}", 1) ) if base_dir is None: @@ -81,7 +81,7 @@ def generate_so_file(cipher_key: str, d: int, n: int, base_dir: Optional[Path] = loader_origin_file_path.touch(exist_ok=True) loader_origin_file_path.write_text(f"{decrypt_source}\n{loader_source}") - loader_file_path.write_text(python_minifier.minify(loader_origin_file_path.read_text())) + loader_file_path.write_text(python_minifier.minify(loader_origin_file_path.read_text(encoding="utf-8"))) from setuptools import setup # isort:skip from Cython.Build import cythonize