diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-06-25 20:54:35 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-06-25 20:54:35 (GMT) |
commit | 93037498d1f61f31e5b52d2f8d4aa437a26bc14e (patch) | |
tree | f538d8f9b5dbcba7473bb454c92206c5b9426884 /Modules/_datetimemodule.c | |
parent | 5ac1b936ef00841e6c5452d1ef360ab539d31dc2 (diff) | |
download | cpython-93037498d1f61f31e5b52d2f8d4aa437a26bc14e.zip cpython-93037498d1f61f31e5b52d2f8d4aa437a26bc14e.tar.gz cpython-93037498d1f61f31e5b52d2f8d4aa437a26bc14e.tar.bz2 |
Fix time.mktime() and datetime.datetime.timestamp() on AIX
On AIX, the C function mktime() alwaysd sets tm_wday, even on error. So tm_wday
cannot be used as a sentinel to detect an error, we can only check if the
result is (time_t)-1.
Diffstat (limited to 'Modules/_datetimemodule.c')
-rw-r--r-- | Modules/_datetimemodule.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index 8f60972..46f38c5 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -4873,9 +4873,16 @@ datetime_timestamp(PyDateTime_DateTime *self) time.tm_wday = -1; time.tm_isdst = -1; timestamp = mktime(&time); - /* Return value of -1 does not necessarily mean an error, but tm_wday - * cannot remain set to -1 if mktime succeeded. */ - if (timestamp == (time_t)(-1) && time.tm_wday == -1) { + if (timestamp == (time_t)(-1) +#ifndef _AIX + /* Return value of -1 does not necessarily mean an error, + * but tm_wday cannot remain set to -1 if mktime succeeded. */ + && time.tm_wday == -1 +#else + /* on AIX, tm_wday is always sets, even on error */ +#endif + ) + { PyErr_SetString(PyExc_OverflowError, "timestamp out of range"); return NULL; |