python / python/cpython

platform.libc_ver() raises TypeError on a threaded libc without a version

Open
#155,454 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

platform.libc_ver() raises TypeError when it scans a binary that references
a threaded C library (such as libc_r) with no version number:

>>> platform.libc_ver(executable=some_binary_referencing_libc_r_so)
Traceback (most recent call last):
  ...
TypeError: 'NoneType' object is not subscriptable

In the so branch of the scanning loop, when a match has a thread suffix
(_r/_pthread) but no version, ver is still None and gets subscripted.
This is a regression from gh-90548 (PR #131313), so 3.14 and later are affected.

CPython versions tested on:

3.16 (main)

Operating systems tested on:

Linux, macOS

Linked PRs
  • gh-155455

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with platform.libc_ver() and its so branch in the scanning loop, then review linked PR gh-155455 before making changes. Reproduce the case with a binary referencing a threaded C library without a version, and consider the issue resolved when the call no longer raises the reported TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
operating-systems
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.