Skip to content

Conversation

@pganssle
Copy link
Member

@pganssle pganssle commented Nov 9, 2017

Fixes #293.

@jbrockmendel Let me know if I missed something here, but it seems like all this checking for missed year tokens is unnecessary since _ymd is remembering which one is the year in the first place. This also allows us to drop the time string from _ymd (it didn't belong there anyway).

@pganssle pganssle requested a review from jbrockmendel November 9, 2017 20:44
@pganssle pganssle added the parser label Nov 9, 2017
@pganssle pganssle added this to the 2.7.0 milestone Nov 9, 2017
@pganssle pganssle changed the title Use the self.ystridx already found for unambiguous year > 99 dates Use the self.ystridx already found for unambiguous year < 99 dates Nov 9, 2017

class _ymd(list):
def __init__(self, tzstr, *args, **kwargs):
def __init__(self, *args, **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for dropping this.

ymd.append(value, 'M')
else:
raise InvalidDatetimeError(ymd.tzstr)
raise InvalidDatetimeError()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Admittedly accessing the input via ymd.tzstr was a bit of a kludge, but it still seems like it should be included in the exception msg. Maybe attach it to res since that is kind of a ParseState?

While we're at it, maybe truncate the string that goes in there at, say, 128 characters?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for any of that. For one thing, none of these exceptions ever made it out of _parse, because they all got caught and raised as ValueError for whatever reason.

If we want to fix that as part of the cleanup, we can just catch, attach the string in the _parse scope, then re-raise.

@jbrockmendel
Copy link
Contributor

Is there a test case to go with this?

@pganssle
Copy link
Member Author

Oops, good point.

@jbrockmendel
Copy link
Contributor

Contingent on a test case, this gets a "LGTM"

@pganssle
Copy link
Member Author

OK, test case added, so merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants