Skip to content

Commit 5f57f9e

Browse files
Jayman2000adrienverge
authored andcommitted
tests: Use correct encoding for path
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>
1 parent 325fafa commit 5f57f9e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tests/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def build_temp_workspace(files):
8787
tempdir = tempfile.mkdtemp(prefix='yamllint-tests-')
8888

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

0 commit comments

Comments
 (0)