File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -4,10 +4,12 @@ Changes relevant to the users of python-tcod are documented here.
44This project adheres to [ Semantic Versioning] ( https://semver.org/ ) since version ` 2.0.0 ` .
55
66## [ Unreleased]
7+ ### Fixed
8+ - Ignore the locale when encoding file paths outside of Windows.
79
810## [ 16.2.1] - 2023-09-24
911### Fixed
10- - Fixed errors loading files where their paths are non-ASCII and the C locale is not UTF-8.
12+ - Fixed errors loading files on Windows where their paths are non-ASCII and the locale is not UTF-8.
1113
1214## [ 16.2.0] - 2023-09-20
1315### Changed
Original file line number Diff line number Diff line change @@ -130,9 +130,11 @@ def _fmt(string: str, stacklevel: int = 2) -> bytes:
130130
131131
132132def _path_encode (path : Path ) -> bytes :
133- """Return a bytes file path for the current C locale."""
133+ """Return a bytes file path for the current locale when on Windows, uses fsdecode for other platforms."""
134+ if sys .platform != "win32" :
135+ return bytes (path ) # Sane and expected behavior for converting Path into bytes
134136 try :
135- return str (path ).encode (locale .getlocale ()[1 ] or "utf-8" )
137+ return str (path ).encode (locale .getlocale ()[1 ] or "utf-8" ) # Stay classy, Windows
136138 except UnicodeEncodeError as exc :
137139 if sys .version_info >= (3 , 11 ):
138140 exc .add_note ("""Consider calling 'locale.setlocale(locale.LC_CTYPES, ".UTF8")' to support Unicode paths.""" )
You can’t perform that action at this time.
0 commit comments