Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b2b42dd

Browse files
committed
The functions asctime() and mktime() are documented to take a 9-tuple
only. Through some mysterious interaction, they would take 9 separate arguments as well. This misfeature is now disabled (to end a difference with JPython).
1 parent 687ef6e commit b2b42dd

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

Modules/timemodule.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,12 @@ time_asctime(self, args)
452452
PyObject *self;
453453
PyObject *args;
454454
{
455+
PyObject *tup;
455456
struct tm buf;
456457
char *p;
457-
if (!gettmarg(args, &buf))
458+
if (!PyArg_ParseTuple(args, "O", &tup))
459+
return NULL;
460+
if (!gettmarg(tup, &buf))
458461
return NULL;
459462
p = asctime(&buf);
460463
if (p[24] == '\n')
@@ -500,11 +503,14 @@ time_mktime(self, args)
500503
PyObject *self;
501504
PyObject *args;
502505
{
506+
PyObject *tup;
503507
struct tm buf;
504508
time_t tt;
509+
if (!PyArg_ParseTuple(args, "O", &tup))
510+
return NULL;
505511
tt = time(&tt);
506512
buf = *localtime(&tt);
507-
if (!gettmarg(args, &buf))
513+
if (!gettmarg(tup, &buf))
508514
return NULL;
509515
tt = mktime(&buf);
510516
if (tt == (time_t)(-1)) {
@@ -529,10 +535,10 @@ static PyMethodDef time_methods[] = {
529535
{"sleep", time_sleep, 0, sleep_doc},
530536
{"gmtime", time_gmtime, 0, gmtime_doc},
531537
{"localtime", time_localtime, 0, localtime_doc},
532-
{"asctime", time_asctime, 0, asctime_doc},
538+
{"asctime", time_asctime, 1, asctime_doc},
533539
{"ctime", time_ctime, 0, ctime_doc},
534540
#ifdef HAVE_MKTIME
535-
{"mktime", time_mktime, 0, mktime_doc},
541+
{"mktime", time_mktime, 1, mktime_doc},
536542
#endif
537543
#ifdef HAVE_STRFTIME
538544
{"strftime", time_strftime, 1, strftime_doc},

0 commit comments

Comments
 (0)