]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-94526: getpath_dirname() no longer encodes the path (#97645)
authorVictor Stinner <vstinner@python.org>
Fri, 30 Sep 2022 12:58:30 +0000 (14:58 +0200)
committerGitHub <noreply@github.com>
Fri, 30 Sep 2022 12:58:30 +0000 (14:58 +0200)
commit9f2f1dd131b912e224cd0269adde8879799686c4
treeb9976f4716a607ec95f03d02bff872b0e33e710b
parentff54dd96cbe589635ed95c8b5b26bc768166b07d
gh-94526: getpath_dirname() no longer encodes the path (#97645)

Fix the Python path configuration used to initialized sys.path at
Python startup. Paths are no longer encoded to UTF-8/strict to avoid
encoding errors if it contains surrogate characters (bytes paths are
decoded with the surrogateescape error handler).

getpath_basename() and getpath_dirname() functions no longer encode
the path to UTF-8/strict, but work directly on Unicode strings. These
functions now use PyUnicode_FindChar() and PyUnicode_Substring() on
the Unicode path, rather than strrchr() on the encoded bytes string.
Misc/NEWS.d/next/Core and Builtins/2022-09-29-15-19-29.gh-issue-94526.wq5m6T.rst [new file with mode: 0644]
Modules/getpath.c