Skip to content

Commit e7f7094

Browse files
kadamskidpgeorge
authored andcommitted
rp2/machine_rtc: Check return value from rtc_set_datetime.
The rtc_set_datetime() from pico-sdk will validate the values in the datetime_t structure and refuse to set the time if they aren't valid. It makes sense to raise an exception if this happens instead of failing silently which might be confusing (as an example, see: micropython#6928 (comment) ).
1 parent 66115a3 commit e7f7094

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ports/rp2/machine_rtc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ STATIC mp_obj_t machine_rtc_datetime(mp_uint_t n_args, const mp_obj_t *args) {
100100
.sec = mp_obj_get_int(items[6]),
101101
};
102102

103-
rtc_set_datetime(&t);
103+
if (!rtc_set_datetime(&t)) {
104+
mp_raise_OSError(MP_EINVAL);
105+
}
104106

105107
}
106108
return mp_const_none;

0 commit comments

Comments
 (0)