Skip to content

Conversation

cjwatson
Copy link
Contributor

@cjwatson cjwatson commented Jun 15, 2025

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.

Pull Request Check List

  • Added tests for changed code.
  • [N/A] Updated documentation for changed code.

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.
Copy link

codspeed-hq bot commented Jun 15, 2025

CodSpeed Performance Report

Merging #903 will not alter performance

Comparing cjwatson:pure-python-empty-duration (ce1220a) with master (fc386be)

Summary

✅ 1 untouched benchmarks

@ashb ashb merged commit 4de9ee8 into python-pendulum:master Jul 16, 2025
18 checks passed
@cjwatson cjwatson deleted the pure-python-empty-duration branch July 20, 2025 11:44
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.

2 participants