Bug report
$ LC_ALL=uk_UA.koi8u python3 -c 'import ctypes.util; print(ctypes.util.find_library("c"))'
None
(it returns the library in a UTF-8 or C locale.)
_findLib_ld() runs ld with universal_newlines=True, so communicate() decodes its output in the locale encoding and fails on a localized diagnostic on stderr. The exception is swallowed, so find_library() returns None. The stderr is discarded and the stdout is already decoded with os.fsdecode(), so the output should be read as bytes.
Linked PRs
- gh-154551: Fix ctypes.util.find_library() in non-UTF-8 locales #154552
- [3.15] gh-154551: Fix ctypes.util.find_library() in non-UTF-8 locales (GH-154552) #154555
- [3.14] gh-154551: Fix ctypes.util.find_library() in non-UTF-8 locales (GH-154552) #154556
- [3.13] gh-154551: Fix ctypes.util.find_library() in non-UTF-8 locales (GH-154552) #154557