mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
bpo-34373: fix test_mktime and test_pthread_getcpuclickid tests on AIX (GH-8726)
* Fix test_mktime on AIX by adding code to get mktime to behave the same way as it does on other *nix systems * Fix test_pthread_getcpuclickid in AIX by adjusting the test case expectations when running on AIX in 32-bit mode Patch by Michael Felt.
This commit is contained in:
parent
c465682718
commit
e2926b7248
4 changed files with 57 additions and 20 deletions
|
@ -174,10 +174,15 @@ static PyObject *
|
|||
time_clock_gettime(PyObject *self, PyObject *args)
|
||||
{
|
||||
int ret;
|
||||
int clk_id;
|
||||
struct timespec tp;
|
||||
|
||||
#if defined(_AIX) && (SIZEOF_LONG == 8)
|
||||
long clk_id;
|
||||
if (!PyArg_ParseTuple(args, "l:clock_gettime", &clk_id)) {
|
||||
#else
|
||||
int clk_id;
|
||||
if (!PyArg_ParseTuple(args, "i:clock_gettime", &clk_id)) {
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -972,35 +977,51 @@ time_mktime(PyObject *self, PyObject *tup)
|
|||
{
|
||||
struct tm buf;
|
||||
time_t tt;
|
||||
#ifdef _AIX
|
||||
time_t clk;
|
||||
int year = buf.tm_year;
|
||||
int delta_days = 0;
|
||||
#endif
|
||||
|
||||
if (!gettmarg(tup, &buf,
|
||||
"iiiiiiiii;mktime(): illegal time tuple argument"))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#ifdef _AIX
|
||||
#ifndef _AIX
|
||||
buf.tm_wday = -1; /* sentinel; original value ignored */
|
||||
tt = mktime(&buf);
|
||||
#else
|
||||
/* year < 1902 or year > 2037 */
|
||||
if (buf.tm_year < 2 || buf.tm_year > 137) {
|
||||
if ((buf.tm_year < 2) || (buf.tm_year > 137)) {
|
||||
/* Issue #19748: On AIX, mktime() doesn't report overflow error for
|
||||
* timestamp < -2^31 or timestamp > 2**31-1. */
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"mktime argument out of range");
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
buf.tm_wday = -1; /* sentinel; original value ignored */
|
||||
year = buf.tm_year;
|
||||
/* year < 1970 - adjust buf.tm_year into legal range */
|
||||
while (buf.tm_year < 70) {
|
||||
buf.tm_year += 4;
|
||||
delta_days -= (366 + (365 * 3));
|
||||
}
|
||||
|
||||
buf.tm_wday = -1;
|
||||
clk = mktime(&buf);
|
||||
buf.tm_year = year;
|
||||
|
||||
if ((buf.tm_wday != -1) && delta_days)
|
||||
buf.tm_wday = (buf.tm_wday + delta_days) % 7;
|
||||
|
||||
tt = clk + (delta_days * (24 * 3600));
|
||||
#endif
|
||||
tt = mktime(&buf);
|
||||
/* Return value of -1 does not necessarily mean an error, but tm_wday
|
||||
* cannot remain set to -1 if mktime succeeded. */
|
||||
if (tt == (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. */
|
||||
&& buf.tm_wday == -1
|
||||
#else
|
||||
/* on AIX, tm_wday is always sets, even on error */
|
||||
#endif
|
||||
)
|
||||
&& buf.tm_wday == -1)
|
||||
{
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"mktime argument out of range");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue