Make empty durations an error in pure-Python parser#903
Merged
ashb merged 1 commit intopython-pendulum:masterfrom Jul 16, 2025
Merged
Make empty durations an error in pure-Python parser#903ashb merged 1 commit intopython-pendulum:masterfrom
ashb merged 1 commit intopython-pendulum:masterfrom
Conversation
Some of Debian's test runners noticed that the pydantic-extra-types
tests are failing on 32-bit architectures:
______________________ test_invalid_zero_duration_string _______________________
def test_invalid_zero_duration_string():
"""'P' is not a valid ISO 8601 duration and should raise a validation error."""
> with pytest.raises(ValidationError):
E Failed: DID NOT RAISE <class 'pydantic_core._pydantic_core.ValidationError'>
tests/test_pendulum_dt.py:447: Failed
Debian currently has pendulum 3.0.0, which disabled the Rust extensions
if `struct.calcsize("P") == 4`, and the Rust and Python parsers disagree
about how to handle an empty duration: the Rust parser reports an error,
while the Python parser returns `Duration()`. 3.1.0 removes that
particular limitation on using Rust extensions on 32-bit architectures,
but the parser discrepancy still seems to be present.
I don't have access to the full text of the standard, but Wikipedia's
summary says 'However, at least one element must be present, thus "P" is
not a valid representation for a duration of 0 seconds', so I think the
Rust parser is correct. Adjust the Python parser to match.
CodSpeed Performance ReportMerging #903 will not alter performanceComparing Summary
|
ashb
approved these changes
Jul 16, 2025
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.
Some of Debian's test runners noticed that the pydantic-extra-types tests are failing on 32-bit architectures:
Debian currently has pendulum 3.0.0, which disabled the Rust extensions if
struct.calcsize("P") == 4, and the Rust and Python parsers disagree about how to handle an empty duration: the Rust parser reports an error, while the Python parser returnsDuration(). 3.1.0 removes that particular limitation on using Rust extensions on 32-bit architectures, but the parser discrepancy still seems to be present.I don't have access to the full text of the standard, but Wikipedia's summary says 'However, at least one element must be present, thus "P" is not a valid representation for a duration of 0 seconds', so I think the Rust parser is correct. Adjust the Python parser to match.
Pull Request Check List