| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
pendulum.parse treats 'A/B' as an ISO 8601 interval. When one side parses to a date and the other to a bare time (e.g. '2020-01-01/12:30:00'), building the interval does Time - date and raised a bare TypeError out of parse(). Same for time/time and time/date. Convert that TypeError into a ParserError so callers get the documented parse error instead.
|
Hi! Gentle nudge on this one whenever you have some bandwidth. It's a small, self-contained fix (Raise ParserError for an interval with mismatched endpoint types), and it's currently mergeable with no conflicts. No urgency at all, and I'm happy to make any changes you'd like. Thanks for maintaining pendulum! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
pendulum.parse('2020-01-01/12:30:00') raises TypeError: unsupported operand type(s) for -: 'Time' and 'datetime.date' instead of a ParserError.
The / makes parse treat the string as an ISO 8601 interval. Here one side parses to a date and the other to a bare time, and building the interval computes end - start (Time - date), which is undefined. The same happens for time/time (12:00:00/13:00:00) and time/date. Valid intervals (datetime/datetime, date/date) are unaffected.
I wrapped the two-endpoint pendulum.interval(...) construction in _parse so a TypeError there is re-raised as ParserError, which is what parse already raises for other invalid input (and it subclasses ValueError, so existing except ValueError handlers still work).
Added a test in test_parsing.py covering the mismatched cases; it raises TypeError on master and passes with the change, and the rest of the parsing tests still pass. Found it by fuzzing parse with mutated date strings.