This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author crwilcox
Recipients Raghunath Lingutla, belopolsky, crwilcox
Date 2018-06-22.23:22:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1529709775.08.0.56676864532.issue33941@psf.upfronthosting.co.za>
In-reply-to
Content
I looked a bit at _strptime.py and the corresponding tests and thought I would share my notes.

The regular expressions clearly allow non-zero padded values for both %d and %m matches. There is one test where the following is run: time.strptime("Mar 1", "%b %d"). So it seems intentional that %d and %m allow non-zero padded values.

It also just occurred to me that the example '181223' isn't ambiguous as %Y requires 4 digits and months cannot be more than 12. So it seems to me this could only be Y=1812,M=2,D=3.

There do exist cases in which they are truly ambiguous for non-zero padded values. For instance, 2018111 could potentially be 2018-Nov-1 or 2018-Jan-11. Python will deterministically take the most possible for the next value, so this will be November 11, 2018. Though, there is really no reason I can figure that can be assumed.

The edits required to stop allowing non-zero padded values were pretty straightforward and only one unit test (one that verifies 'Mar 1' comes after 'Feb 29') had to be altered. That may point more to a need to add additional tests though than an endorsement that no one is using single digit day or month values.
History
Date User Action Args
2018-06-22 23:22:55crwilcoxsetrecipients: + crwilcox, belopolsky, Raghunath Lingutla
2018-06-22 23:22:55crwilcoxsetmessageid: <1529709775.08.0.56676864532.issue33941@psf.upfronthosting.co.za>
2018-06-22 23:22:55crwilcoxlinkissue33941 messages
2018-06-22 23:22:54crwilcoxcreate