Commit 4de9ee8
Make empty durations an error in pure-Python parser
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.1 parent c8068a7 commit 4de9ee8
File tree
2 files changed
+9
-3
lines changed- src/pendulum/parsing
- tests/parsing
2 files changed
+9
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
268 | | - | |
| 268 | + | |
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| |||
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
196 | | - | |
| 196 | + | |
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
0 commit comments