Skip to content

Fix incorrect index check, add test that fails pre-PR#420

Merged
pganssle merged 1 commit into
dateutil:masterfrom
jbrockmendel:fix_idxcheck
Jul 18, 2017
Merged

Fix incorrect index check, add test that fails pre-PR#420
pganssle merged 1 commit into
dateutil:masterfrom
jbrockmendel:fix_idxcheck

Conversation

@jbrockmendel

Copy link
Copy Markdown
Contributor

In the status-quo, L824-825 checks:

                        if i < len_l and l[i] == ':':
                            res.second, res.microsecond = _parsems(l[i+1])

Avoiding an IndexError requires checking i+1 < len_l. This is easy to miss because the try/except catches IndexError. One way to trigger this is:

import dateutil.parser
dateutil.parser.IndexError = SyntaxError
dateutil.parser.parse('2017-07-17 06:21:', fuzzy=True)

@pganssle pganssle added this to the 2.7.0 milestone Jul 18, 2017
@pganssle

Copy link
Copy Markdown
Member

Ugh, this giant try/catch block really has to go.

@pganssle
pganssle merged commit 7f9d40a into dateutil:master Jul 18, 2017
@jbrockmendel
jbrockmendel deleted the fix_idxcheck branch July 18, 2017 03:11
@pganssle pganssle mentioned this pull request Mar 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants