serhiy-storchaka · GitHub

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

Read the original on github.com ↗