From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Fri, 24 Jul 2026 16:32:37 +0000 (+0200) Subject: [3.13] gh-154551: Fix ctypes.util.find_library() in non-UTF-8 locales (GH-154552... X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=9d934655a6f8cf18576c9833af999295b4fc5001;p=thirdparty%2FPython%2Fcpython.git [3.13] gh-154551: Fix ctypes.util.find_library() in non-UTF-8 locales (GH-154552) (GH-154557) _findLib_ld() failed to decode the localized "ld" stderr in the locale encoding. (cherry picked from commit 66e313f471516bfa04c5c8966c159fafe6be082e) Co-authored-by: Serhiy Storchaka Co-authored-by: Claude Opus 4.8 --- diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py index 117bf06cb010..43f10dedce8c 100644 --- a/Lib/ctypes/util.py +++ b/Lib/ctypes/util.py @@ -321,8 +321,7 @@ elif os.name == "posix": result = None try: p = subprocess.Popen(cmd, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - universal_newlines=True) + stderr=subprocess.PIPE) out, _ = p.communicate() res = re.findall(expr, os.fsdecode(out)) for file in res: diff --git a/Misc/NEWS.d/next/Library/2026-07-23-19-45-00.gh-issue-154551.Ct7pL9.rst b/Misc/NEWS.d/next/Library/2026-07-23-19-45-00.gh-issue-154551.Ct7pL9.rst new file mode 100644 index 000000000000..c4db19d89364 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-07-23-19-45-00.gh-issue-154551.Ct7pL9.rst @@ -0,0 +1 @@ +Fix :func:`ctypes.util.find_library` returning ``None`` in non-UTF-8 locales.