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 belopolsky
Recipients Saimadhav.Heblikar, belopolsky, jamercee, lemburg, serhiy.storchaka, torm
Date 2014-12-31.18:05:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1420049148.22.0.159331209677.issue23136@psf.upfronthosting.co.za>
In-reply-to
Content
I would prefer to accept "denormalized" "%Y %W %w" combinations.  Note that while Mac OSX and glibc versions of strptime produce different results, neither implementation signals an error by returning NULL.

> In C the strptime function doesn't return valid date for such input.

This is not true.  In C, struct tm is not required to contain normalized data.  I am attaching a modified version of Serhiy's strptimetest.c:

$ diff -u strptimetest.c strptimetest2.c
--- strptimetest.c	2014-12-30 13:45:17.000000000 -0500
+++ strptimetest2.c	2014-12-31 12:56:17.000000000 -0500
@@ -16,6 +16,7 @@
         exit(1);
     }
     strptime(argv[1], argv[2], &tm);
+    mktime(&tm);
     strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &tm);
     puts(buf);
     return 0;

With this modification, I get on Linux

$ ./a.out "0 2015 2" "%W %Y %w"
2014-11-29 00:00:00

which is still wrong, but I think this is a glibc issue: mktime accepted strptime result as valid even though it failed to normalize it correctly.
History
Date User Action Args
2014-12-31 18:05:48belopolskysetrecipients: + belopolsky, lemburg, serhiy.storchaka, jamercee, Saimadhav.Heblikar, torm
2014-12-31 18:05:48belopolskysetmessageid: <1420049148.22.0.159331209677.issue23136@psf.upfronthosting.co.za>
2014-12-31 18:05:48belopolskylinkissue23136 messages
2014-12-31 18:05:47belopolskycreate