From 798c793dc298c70e97a56ce5112d7c3c5f66b9e3 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Thu, 23 Jul 2026 19:32:11 +0300 Subject: [PATCH] gh-154551: Fix ctypes.util.find_library() in non-UTF-8 locales _findLib_ld() failed to decode the localized "ld" stderr in the locale encoding. Co-Authored-By: Claude Opus 4.8 --- Lib/ctypes/util.py | 3 +-- .../Library/2026-07-23-19-45-00.gh-issue-154551.Ct7pL9.rst | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2026-07-23-19-45-00.gh-issue-154551.Ct7pL9.rst diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py index a73422598b2cd96..5c33a4ab522ea4f 100644 --- a/Lib/ctypes/util.py +++ b/Lib/ctypes/util.py @@ -429,8 +429,7 @@ def _findLib_ld(name): 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 000000000000000..c4db19d89364e07 --- /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.