Skip to content

ctypes.util.find_library() returns None in non-UTF-8 locales #154551

Closed

Description

@serhiy-storchaka

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

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    3.13only security fixes
    3.14bugs and security fixes
    3.15bugs and security fixes
    3.16new features, bugs and security fixes
    on Jul 23, 2026
  2. added 4 commits that reference this issue on Jul 23, 2026
  3. added a commit that references this issue on Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13only security fixes3.14bugs and security fixes3.15bugs and security fixes3.16new features, bugs and security fixestopic-ctypestype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions