diff --git a/lamindb_setup/core/_private_django_api.py b/lamindb_setup/core/_private_django_api.py index 3b9a2dda0..8269a9064 100644 --- a/lamindb_setup/core/_private_django_api.py +++ b/lamindb_setup/core/_private_django_api.py @@ -58,8 +58,10 @@ def private_django_api(reverse=False): django_path = Path(db.__file__).parent.parent + encoding = "utf8" if os.name == "nt" else None + def prune_file(file_path): - content = file_path.read_text() + content = file_path.read_text(encoding=encoding) original_content = content for attr in attributes: @@ -72,7 +74,7 @@ def prune_file(file_path): content = content.replace("Object_DoesNotExist", "ObjectDoesNotExist") if content != original_content: - file_path.write_text(content) + file_path.write_text(content, encoding=encoding) for file_path in django_path.rglob("*.py"): prune_file(file_path)