Repository navigation
Fix parse_date raising TypeError for dates without a time or seconds - #2245
Open
aad1tyaaaaa wants to merge 2 commits into
Open
aad1tyaaaaa wants to merge 2 commits into
aad1tyaaaaa wants to merge 2 commits into
Conversation
The regex makes everything after the year optional, but the missing groups were passed to int() as None. Default them like upstream pyiso8601 does.
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.
Fix parse_date raising TypeError for dates without a time or seconds
Description
libcloud.utils.iso8601.parse_dateraisesTypeErrorinstead of parsing valid ISO 8601 strings that leave out the time or the seconds:ISO8601_REGEXmakes everything after the year optional, so these strings match, but the missing groups areNoneand go straight intoint(). Upstream pyiso8601, which this module comes from, defaults them (month and day to 1, the time fields to 0); this change does the same. Strings with every field parse exactly as before.This is independent of #2243 (fractional seconds), and the two branches merge cleanly.
Status
Checklist
black,isort)CHANGES.rstentry)test_parse_date_without_time_or_secondsinlibcloud/test/test_utils.py(2020-01-01,2020-01-01T10:20Z,2020-01-01T10:20+02:00) fails on trunk and passes with this change; the compute, common and backup test suites pass.I used an AI assistant (Claude Code) to help find this bug and write the fix and test. I reviewed and ran everything myself.