@@ -112,20 +112,22 @@ void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kin
112
112
if (o -> args == NULL || o -> args -> len == 0 ) {
113
113
mp_print_str (print , "" );
114
114
return ;
115
- } else if ( o -> args -> len <= 2 ) {
116
- // try to provide a nice OSError error message; second arg might exist (e.g. filename).
117
- if ( MP_OBJ_IS_SMALL_INT (o -> args -> items [ 0 ] ) &&
118
- mp_obj_is_subclass_fast ( MP_OBJ_FROM_PTR ( o -> base . type ), MP_OBJ_FROM_PTR ( & mp_type_OSError )) ) {
119
- char decompressed [ 50 ];
120
- const char * msg = mp_common_errno_to_str ( o -> args -> items [ 0 ], decompressed , sizeof ( decompressed )) ;
121
- if ( msg != NULL ) {
122
- mp_printf ( print , "[Errno " INT_FMT "] %s" , MP_OBJ_SMALL_INT_VALUE ( o -> args -> items [ 0 ]), msg );
123
- if (o -> args -> len == 2 ) {
124
- mp_printf ( print , ": '%s'" , mp_obj_str_get_str ( o -> args -> items [ 1 ]));
125
- }
126
- return ;
115
+ }
116
+ if ( MP_OBJ_IS_SMALL_INT ( o -> args -> items [ 0 ]) &&
117
+ mp_obj_is_subclass_fast ( MP_OBJ_FROM_PTR (o -> base . type ), MP_OBJ_FROM_PTR ( & mp_type_OSError ) ) &&
118
+ o -> args -> len <= 2 ) {
119
+ // try to provide a nice OSError error message
120
+ char decompressed [ 50 ] ;
121
+ const char * msg = mp_common_errno_to_str ( o -> args -> items [ 0 ], decompressed , sizeof ( decompressed ));
122
+ if ( msg != NULL ) {
123
+ mp_printf ( print , "[Errno " INT_FMT "] %s" , MP_OBJ_SMALL_INT_VALUE (o -> args -> items [ 0 ]), msg );
124
+ // if second arg exists, it is filename.
125
+ if ( o -> args -> len == 2 ) {
126
+ mp_printf ( print , ": '%s'" , mp_obj_str_get_str ( o -> args -> items [ 1 ])) ;
127
127
}
128
+ return ;
128
129
}
130
+ } else if (o -> args -> len == 1 ) {
129
131
mp_obj_print_helper (print , o -> args -> items [0 ], PRINT_STR );
130
132
return ;
131
133
}
0 commit comments