@@ -68,7 +68,7 @@ STATIC microbit_image_obj_t *image_from_parsed_str(const char *s, mp_int_t len)
6868 } else if ('c' >= '0' && c <= '9' ) {
6969 ++ line_len ;
7070 } else {
71- mp_raise_ValueError ("unexpected character in Image definition" );
71+ mp_raise_ValueError (MP_ERROR_TEXT ( "unexpected character in Image definition" ) );
7272 }
7373 }
7474 if (line_len ) {
@@ -133,7 +133,7 @@ STATIC mp_obj_t microbit_image_make_new(const mp_obj_type_t *type_in, mp_uint_t
133133 return image_from_parsed_str (str , len );
134134 }
135135 } else {
136- mp_raise_TypeError ("Image(s) takes a string" );
136+ mp_raise_TypeError (MP_ERROR_TEXT ( "Image(s) takes a string" ) );
137137 }
138138 }
139139
@@ -149,7 +149,7 @@ STATIC mp_obj_t microbit_image_make_new(const mp_obj_type_t *type_in, mp_uint_t
149149 mp_get_buffer_raise (args [2 ], & bufinfo , MP_BUFFER_READ );
150150
151151 if (w < 0 || h < 0 || (size_t )(w * h ) != bufinfo .len ) {
152- mp_raise_ValueError ("image data is incorrect size" );
152+ mp_raise_ValueError (MP_ERROR_TEXT ( "image data is incorrect size" ) );
153153 }
154154 mp_int_t i = 0 ;
155155 for (mp_int_t y = 0 ; y < h ; y ++ ) {
@@ -164,7 +164,7 @@ STATIC mp_obj_t microbit_image_make_new(const mp_obj_type_t *type_in, mp_uint_t
164164 }
165165
166166 default : {
167- mp_raise_TypeError ("Image() takes 0 to 3 arguments" );
167+ mp_raise_TypeError (MP_ERROR_TEXT ( "Image() takes 0 to 3 arguments" ) );
168168 }
169169 }
170170}
@@ -205,19 +205,19 @@ mp_obj_t microbit_image_get_pixel(mp_obj_t self_in, mp_obj_t x_in, mp_obj_t y_in
205205 mp_int_t x = mp_obj_get_int (x_in );
206206 mp_int_t y = mp_obj_get_int (y_in );
207207 if (x < 0 || y < 0 ) {
208- mp_raise_ValueError ("index cannot be negative" );
208+ mp_raise_ValueError (MP_ERROR_TEXT ( "index cannot be negative" ) );
209209 }
210210 if (x < image_width (self ) && y < image_height (self )) {
211211 return MP_OBJ_NEW_SMALL_INT (image_get_pixel (self , x , y ));
212212 }
213- mp_raise_ValueError ("index too large" );
213+ mp_raise_ValueError (MP_ERROR_TEXT ( "index too large" ) );
214214}
215215MP_DEFINE_CONST_FUN_OBJ_3 (microbit_image_get_pixel_obj , microbit_image_get_pixel );
216216
217217/* Raise an exception if not mutable */
218218static void check_mutability (microbit_image_obj_t * self ) {
219219 if (self -> base .five ) {
220- mp_raise_TypeError ("image cannot be modified (try copying first)" );
220+ mp_raise_TypeError (MP_ERROR_TEXT ( "image cannot be modified (try copying first)" ) );
221221 }
222222}
223223
@@ -228,17 +228,17 @@ mp_obj_t microbit_image_set_pixel(mp_uint_t n_args, const mp_obj_t *args) {
228228 mp_int_t x = mp_obj_get_int (args [1 ]);
229229 mp_int_t y = mp_obj_get_int (args [2 ]);
230230 if (x < 0 || y < 0 ) {
231- mp_raise_ValueError ("index cannot be negative" );
231+ mp_raise_ValueError (MP_ERROR_TEXT ( "index cannot be negative" ) );
232232 }
233233 mp_int_t bright = mp_obj_get_int (args [3 ]);
234234 if (bright < 0 || bright > MICROBIT_DISPLAY_MAX_BRIGHTNESS ) {
235- mp_raise_ValueError ("brightness out of bounds" );
235+ mp_raise_ValueError (MP_ERROR_TEXT ( "brightness out of bounds" ) );
236236 }
237237 if (x < image_width (self ) && y < image_height (self )) {
238238 greyscale_set_pixel (& self -> greyscale , x , y , bright );
239239 return mp_const_none ;
240240 }
241- mp_raise_ValueError ("index too large" );
241+ mp_raise_ValueError (MP_ERROR_TEXT ( "index too large" ) );
242242}
243243MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (microbit_image_set_pixel_obj , 4 , 4 , microbit_image_set_pixel );
244244
@@ -247,7 +247,7 @@ mp_obj_t microbit_image_fill(mp_obj_t self_in, mp_obj_t n_in) {
247247 check_mutability (self );
248248 mp_int_t n = mp_obj_get_int (n_in );
249249 if (n < 0 || n > MICROBIT_DISPLAY_MAX_BRIGHTNESS ) {
250- mp_raise_ValueError ("brightness out of bounds" );
250+ mp_raise_ValueError (MP_ERROR_TEXT ( "brightness out of bounds" ) );
251251 }
252252 greyscale_fill (& self -> greyscale , n );
253253 return mp_const_none ;
@@ -260,17 +260,17 @@ mp_obj_t microbit_image_blit(mp_uint_t n_args, const mp_obj_t *args) {
260260
261261 mp_obj_t src = args [1 ];
262262 if (mp_obj_get_type (src ) != & microbit_image_type ) {
263- mp_raise_TypeError ("expecting an image" );
263+ mp_raise_TypeError (MP_ERROR_TEXT ( "expecting an image" ) );
264264 }
265265 if (n_args == 7 ) {
266- mp_raise_TypeError ("must specify both offsets" );
266+ mp_raise_TypeError (MP_ERROR_TEXT ( "must specify both offsets" ) );
267267 }
268268 mp_int_t x = mp_obj_get_int (args [2 ]);
269269 mp_int_t y = mp_obj_get_int (args [3 ]);
270270 mp_int_t w = mp_obj_get_int (args [4 ]);
271271 mp_int_t h = mp_obj_get_int (args [5 ]);
272272 if (w < 0 || h < 0 ) {
273- mp_raise_ValueError ("size cannot be negative" );
273+ mp_raise_ValueError (MP_ERROR_TEXT ( "size cannot be negative" ) );
274274 }
275275 mp_int_t xdest ;
276276 mp_int_t ydest ;
@@ -450,7 +450,7 @@ microbit_image_obj_t *microbit_image_for_char(char c) {
450450
451451microbit_image_obj_t * microbit_image_dim (microbit_image_obj_t * lhs , mp_float_t fval ) {
452452 if (fval < 0 ) {
453- mp_raise_ValueError ("brightness multiplier must not be negative" );
453+ mp_raise_ValueError (MP_ERROR_TEXT ( "brightness multiplier must not be negative" ) );
454454 }
455455 greyscale_t * result = greyscale_new (image_width (lhs ), image_height (lhs ));
456456 for (int x = 0 ; x < image_width (lhs ); ++ x ) {
@@ -466,7 +466,7 @@ STATIC microbit_image_obj_t *microbit_image_sum(microbit_image_obj_t *lhs, micro
466466 mp_int_t h = image_height (lhs );
467467 mp_int_t w = image_width (lhs );
468468 if (image_height (rhs ) != h || image_width (rhs ) != w ) {
469- mp_raise_ValueError ("images must be the same size" );
469+ mp_raise_ValueError (MP_ERROR_TEXT ( "images must be the same size" ) );
470470 }
471471 greyscale_t * result = greyscale_new (w , h );
472472 for (int x = 0 ; x < w ; ++ x ) {
0 commit comments