Skip to content

Commit b10998e

Browse files
Address review comments
Restore the default of time.asctime() as NULL, so that passing None raises a TypeError as before, and fix the docstring of time.ctime() and the comment for parse_time_t_arg().
1 parent ca3e771 commit b10998e

3 files changed

Lines changed: 16 additions & 14 deletions

File tree

Lib/test/test_inspect/test_inspect.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6360,7 +6360,9 @@ def test_thread_module_has_signatures(self):
63606360

63616361
def test_time_module_has_signatures(self):
63626362
no_signature = {'strftime', 'strptime'}
6363-
self._test_module_has_signatures(time, no_signature)
6363+
unsupported_signature = {'asctime'}
6364+
self._test_module_has_signatures(time, no_signature,
6365+
unsupported_signature)
63646366

63656367
def test_tokenize_module_has_signatures(self):
63666368
import tokenize

Modules/clinic/timemodule.c.h

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/timemodule.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,8 @@ tmtotuple(time_module_state *state, struct tm *p
509509
return v;
510510
}
511511

512-
/* Parse arg tuple that can contain an optional float-or-None value;
513-
format needs to be "|O:name".
512+
/* Convert a number of seconds since the Epoch, or None which means the
513+
current time, to time_t.
514514
Returns non-zero on success (parallels PyArg_ParseTuple).
515515
*/
516516
static int
@@ -1051,7 +1051,7 @@ _asctime(struct tm *timeptr)
10511051
/*[clinic input]
10521052
time.asctime
10531053
1054-
time_tuple as tup: object = None
1054+
time_tuple as tup: object = NULL
10551055
/
10561056
10571057
Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'.
@@ -1062,12 +1062,12 @@ localtime() is used.
10621062

10631063
static PyObject *
10641064
time_asctime_impl(PyObject *module, PyObject *tup)
1065-
/*[clinic end generated code: output=a1bc45f84a00fb55 input=38a2a45e233a2a95]*/
1065+
/*[clinic end generated code: output=a1bc45f84a00fb55 input=083c132f3cb23f1e]*/
10661066
{
10671067
struct tm buf;
10681068

10691069
time_module_state *state = get_time_state(module);
1070-
if (tup == Py_None) {
1070+
if (tup == NULL) {
10711071
time_t tt = time(NULL);
10721072
if (_PyTime_localtime(tt, &buf) != 0)
10731073
return NULL;
@@ -1089,13 +1089,13 @@ time.ctime
10891089
10901090
Convert a time in seconds since the Epoch to a string in local time.
10911091
1092-
This is equivalent to asctime(localtime(seconds)). When the time tuple
1093-
is not present, current time as returned by localtime() is used.
1092+
This is equivalent to asctime(localtime(seconds)). When 'seconds' is
1093+
not passed in, convert the current time instead.
10941094
[clinic start generated code]*/
10951095

10961096
static PyObject *
10971097
time_ctime_impl(PyObject *module, PyObject *ot)
1098-
/*[clinic end generated code: output=c3a028f5c6931cbc input=7a4cf111320a727b]*/
1098+
/*[clinic end generated code: output=c3a028f5c6931cbc input=ee744f25ce87d1ae]*/
10991099
{
11001100
time_t tt;
11011101
struct tm buf;

0 commit comments

Comments
 (0)