MetaData() crashes in any environment with packaging >= 26.3 - #62
Merged
pnorton-usgs merged 1 commit intoAug 14, 2026
Merged
Conversation
MetaData.__filter_by_version relied on Version(None) raising TypeError to skip elements without version/deprecated XML attributes. packaging 26.3 raises InvalidVersion for None, escaping the handler and crashing MetaData() for any such element (63 in control.xml alone). Check the attributes for None explicitly instead of exception flow; behavior is unchanged on all packaging versions, including InvalidVersion still propagating for genuinely malformed version strings. Also declare the (already imported) packaging dependency in pyproject.toml and add a regression test.
Member
|
This looks good - I just got hit by this problem this morning! Thanks for fixing this. |
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.
Problem
The code relied on Version(None) raising TypeError (packaging
<= 26.2 behavior) to skip elements without a version/deprecated
attribute; packaging 26.3 changed the exception to InvalidVersion,
which escapes the except TypeError handler. 63 entries in the shipped
control.xml lack the attribute, so any MetaData() call crashes.
Found via conda-forge CI for pywatershed 3.0.0, which imports pyPRMS
(conda-forge/pywatershed-feedstock#13); fresh pip environments that
resolve packaging 26.3 hit the same crash.
Fix
Check the XML attributes for None explicitly instead of relying on
exception flow. Behavior is otherwise unchanged on all packaging
versions (including that InvalidVersion still propagates for a
genuinely malformed version string, as it always did).
Declare the already-imported packaging dependency in
pyproject.toml.
Add a regression test (entries with neither attribute, and with only
deprecated, are retained).
A release including this would let downstream consumers drop temporary
packaging <26.3 pins.