Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encode using locale when writing .pth files #8041

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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