Skip to content

Commit

Permalink
tests: Use correct encoding for path
Browse files Browse the repository at this point in the history
Before this change, build_temp_workspace() would always encode a path
using UTF-8 and the strict error handler [1]. Most of the time, this is
fine, but systems do not necessarily use UTF-8 and the strict error
handler for paths [2].

[1]: <https://docs.python.org/3.12/library/stdtypes.html#str.encode>
[2]: <https://docs.python.org/3.12/glossary.html#term-filesystem-encoding-and-error-handler>
  • Loading branch information
Jayman2000 committed Jan 13, 2024
1 parent 0d7ae7b commit 7b41f65
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def build_temp_workspace(files):
tempdir = tempfile.mkdtemp(prefix='yamllint-tests-')

for path, content in files.items():
path = os.path.join(tempdir, path).encode('utf-8')
path = os.fsencode(os.path.join(tempdir, path))
if not os.path.exists(os.path.dirname(path)):
os.makedirs(os.path.dirname(path))

Expand Down

0 comments on commit 7b41f65

Please sign in to comment.