Use the self.ystridx already found for unambiguous year < 99 dates#510
Conversation
|
|
||
| class _ymd(list): | ||
| def __init__(self, tzstr, *args, **kwargs): | ||
| def __init__(self, *args, **kwargs): |
There was a problem hiding this comment.
+1 for dropping this.
| ymd.append(value, 'M') | ||
| else: | ||
| raise InvalidDatetimeError(ymd.tzstr) | ||
| raise InvalidDatetimeError() |
There was a problem hiding this comment.
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.
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).