Skip to content

Commit 8d7c58f

Browse files
authored
Merge pull request #2327 from jepler/issue2326
Make time.time_tuple constructor more CPython3 compatible
2 parents e5dd78d + e188ae8 commit 8d7c58f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

shared-bindings/time/__init__.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ MP_DEFINE_CONST_FUN_OBJ_1(time_sleep_obj, time_sleep);
8585
#if MICROPY_PY_COLLECTIONS
8686
mp_obj_t struct_time_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
8787
if (n_args != 1 || (kw_args != NULL && kw_args->used > 0)) {
88-
mp_raise_TypeError(translate("time.struct_time() takes exactly 1 argument"));
88+
return namedtuple_make_new(type, n_args, args, kw_args);
8989
}
90-
if (!MP_OBJ_IS_TYPE(args[0], &mp_type_tuple) || ((mp_obj_tuple_t*) MP_OBJ_TO_PTR(args[0]))->len != 9) {
90+
if (mp_obj_get_type(args[0])->getiter != mp_obj_tuple_getiter || ((mp_obj_tuple_t*) MP_OBJ_TO_PTR(args[0]))->len != 9) {
9191
mp_raise_TypeError(translate("time.struct_time() takes a 9-sequence"));
9292
}
9393

0 commit comments

Comments
 (0)