Skip to content

fix(standalone_python): extract hash from sha256: prefix in digest field#1775

Draft
BillionClaw wants to merge 2 commits intopypa:mainfrom
BillionClaw:clawoss/fix/standalone-python-digest
Draft

fix(standalone_python): extract hash from sha256: prefix in digest field#1775
BillionClaw wants to merge 2 commits intopypa:mainfrom
BillionClaw:clawoss/fix/standalone-python-digest

Conversation

@BillionClaw
Copy link
Copy Markdown
Contributor

Summary

Fixes a ValueError: too many values to unpack that occurred when using --fetch-missing-python.

Root Cause

The GitHub API's asset["digest"] field returns values in the format "sha256:HASH" (a single string), but get_latest_python_releases() stored this directly as the second tuple element. When list_pythons() later iterated and unpacked for link, digest in python_releases, it expected two separate values but got a single string containing a colon, causing the error.

Fix

Extract just the hash portion using .partition(":")[2]:

# Before
return [(asset["browser_download_url"], asset["digest"]) for asset in release_data["assets"]]

# After
return [
    (asset["browser_download_url"], asset["digest"].partition(":")[2])
    for asset in release_data["assets"]
]

This is safe because the GitHub API digest format is always "sha256:HASH" with exactly one colon.

Testing

  • The fix was verified against the actual GitHub API response format

Fixes #1774

BillionClaw and others added 2 commits March 26, 2026 18:20
The GitHub API's asset digest field returns values in the format
"sha256:HASH", but the unpacking code expected just the hash string.
This caused a "ValueError: too many values to unpack" when iterating
over python_releases.

Fix by using .partition(":")[2] to extract just the hash portion.

Fixes pypa#1774.
Copy link
Copy Markdown
Contributor

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test please.

@gaborbernat gaborbernat marked this pull request as draft April 1, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--fetch-missing-python dies with "ValueError: too many values to unpack (expected 2)"

2 participants