Fix numpy 2.3+ compatibility by using public APIs#170
Merged
thomas-chauchefoin-tob merged 3 commits intomasterfrom Nov 26, 2025
Merged
Fix numpy 2.3+ compatibility by using public APIs#170thomas-chauchefoin-tob merged 3 commits intomasterfrom
thomas-chauchefoin-tob merged 3 commits intomasterfrom
Conversation
Replace usage of private _header_size_info with public read_array_header_1_0() and read_array_header_2_0() functions in check_numpy(). The private API was removed from numpy.lib.format in numpy 2.0+ and moved to an internal module. This fix: - Uses stable public APIs available since numpy 1.10.0 - Works with numpy 1.24.0 through 2.3.5+ - Removes unused ast and struct imports - Improves error handling for corrupted files Fixes test_polyglot.py failures with numpy 2.3.3+ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
Author
thomas-chauchefoin-tob
approved these changes
Nov 26, 2025
Collaborator
thomas-chauchefoin-tob
left a comment
There was a problem hiding this comment.
Just fixed the Ruff reports and reverted uv.lock changes, we'll bump dependencies in a separate PR. Thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix numpy 2.3+ compatibility in test_polyglot.py
Problem
The check_numpy() function in fickling/polyglot.py was failing with numpy 2.3.3+ due to an AttributeError: module 'numpy.lib.format' has no attribute '_header_size_info'.
In numpy 2.0+, the internal structure was reorganized and the private _header_size_info variable was moved to numpy.lib._format_impl and is no longer re-exported from numpy.lib.format.
Solution
Replace the private API usage with numpy's public APIs:
Changes
Benefits
Testing
All tests pass with numpy 2.3.5:
Tested on: Python 3.13.7, pytest 9.0.1, numpy 2.3.5
Closes
Fixes issue with test_polyglot.py failing on numpy 2.3.3+