Skip to content

Commit 8f24ea4

Browse files
committed
time: struct_time: allow construction from another struct_time
This doesn't cover ALL the cases that CPython permits for construction of a struct_time, but it at least makes constructing from any namedtuple work. Closes: #2326
1 parent e5dd78d commit 8f24ea4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

shared-bindings/time/__init__.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ mp_obj_t struct_time_make_new(const mp_obj_type_t *type, size_t n_args, const mp
8787
if (n_args != 1 || (kw_args != NULL && kw_args->used > 0)) {
8888
mp_raise_TypeError(translate("time.struct_time() takes exactly 1 argument"));
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)