From 4a13deb84014d12f8164d11b6c75a888bb887e5e Mon Sep 17 00:00:00 2001 From: NtWriteCode <118625463+NtWriteCode@users.noreply.github.com> Date: Tue, 23 Apr 2024 15:36:58 +0200 Subject: [PATCH] Fixed a case when template variable is WindowsPath (#2707) Co-authored-by: NtWriteCode --- src/virtualenv/activation/via_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/virtualenv/activation/via_template.py b/src/virtualenv/activation/via_template.py index 373316cf5..ab9b90131 100644 --- a/src/virtualenv/activation/via_template.py +++ b/src/virtualenv/activation/via_template.py @@ -48,7 +48,7 @@ def _generate(self, replacements, templates, to_folder, creator): if dest.exists(): dest.unlink() # Powershell assumes Windows 1252 encoding when reading files without BOM - encoding = "utf-8-sig" if template.endswith(".ps1") else "utf-8" + encoding = "utf-8-sig" if str(template).endswith(".ps1") else "utf-8" # use write_bytes to avoid platform specific line normalization (\n -> \r\n) dest.write_bytes(text.encode(encoding)) generated.append(dest)