-
Notifications
You must be signed in to change notification settings - Fork 523
Use the self.ystridx already found for unambiguous year < 99 dates #510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
||
| class _ymd(list): | ||
| def __init__(self, tzstr, *args, **kwargs): | ||
| def __init__(self, *args, **kwargs): |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
|
Is there a test case to go with this? |
|
Oops, good point. |
|
Contingent on a test case, this gets a "LGTM" |
|
OK, test case added, so merging. |
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
_ymdis 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).