Skip to content

Commit

Permalink
Encode using locale when writing .pth files (#8041)
Browse files Browse the repository at this point in the history
  • Loading branch information
savannahostrowski authored Aug 3, 2023
1 parent dfd0db8 commit 9df40a4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/poetry/masonry/builders/editable.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import csv
import hashlib
import json
import locale
import os

from base64 import urlsafe_b64encode
Expand Down Expand Up @@ -126,7 +127,7 @@ def _add_pth(self) -> list[Path]:

try:
pth_file = self._env.site_packages.write_text(
pth_file, content, encoding="utf-8"
pth_file, content, encoding=locale.getpreferredencoding()
)
self._debug(
f" - Adding <c2>{pth_file.name}</c2> to <b>{pth_file.parent}</b> for"
Expand Down
3 changes: 2 additions & 1 deletion tests/masonry/builders/test_editable_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import csv
import json
import locale
import os
import shutil

Expand Down Expand Up @@ -275,7 +276,7 @@ def test_builder_installs_proper_files_when_packages_configured(
pth_file = tmp_venv.site_packages.find(pth_file)[0]

paths = set()
with pth_file.open() as f:
with pth_file.open(encoding=locale.getpreferredencoding()) as f:
for line in f.readlines():
line = line.strip(os.linesep)
if line:
Expand Down

0 comments on commit 9df40a4

Please sign in to comment.