py: Shorten error messages by using contractions and some rewording.
diff --git a/py/argcheck.c b/py/argcheck.c
index c018f3f..c2b1b6c 100644
--- a/py/argcheck.c
+++ b/py/argcheck.c
@@ -41,7 +41,7 @@
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_arg_error_terse_mismatch();
} else {
- mp_raise_TypeError("function does not take keyword arguments");
+ mp_raise_TypeError("function doesn't take keyword arguments");
}
}
diff --git a/py/compile.c b/py/compile.c
index 5748256..4cc6ab9 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -2826,7 +2826,7 @@
bool added;
id_info_t *id_info = scope_find_or_add_id(comp->scope_cur, param_name, &added);
if (!added) {
- compile_syntax_error(comp, pn, "name reused for argument");
+ compile_syntax_error(comp, pn, "argument name reused");
return;
}
id_info->kind = ID_INFO_KIND_LOCAL;
diff --git a/py/emitinlinethumb.c b/py/emitinlinethumb.c
index 577f656..0649c59 100644
--- a/py/emitinlinethumb.c
+++ b/py/emitinlinethumb.c
@@ -301,7 +301,7 @@
}
uint32_t i = mp_obj_get_int_truncated(o);
if ((i & (~fit_mask)) != 0) {
- emit_inline_thumb_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "'%s' integer 0x%x does not fit in mask 0x%x", op, i, fit_mask));
+ emit_inline_thumb_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "'%s' integer 0x%x doesn't fit in mask 0x%x", op, i, fit_mask));
return 0;
}
return i;
diff --git a/py/emitinlinextensa.c b/py/emitinlinextensa.c
index 3d3217f..b5f9189 100644
--- a/py/emitinlinextensa.c
+++ b/py/emitinlinextensa.c
@@ -171,7 +171,7 @@
}
uint32_t i = mp_obj_get_int_truncated(o);
if (min != max && ((int)i < min || (int)i > max)) {
- emit_inline_xtensa_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "'%s' integer %d is not within range %d..%d", op, i, min, max));
+ emit_inline_xtensa_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "'%s' integer %d isn't within range %d..%d", op, i, min, max));
return 0;
}
return i;
diff --git a/py/modmath.c b/py/modmath.c
index 7eda759..6072c78 100644
--- a/py/modmath.c
+++ b/py/modmath.c
@@ -187,7 +187,7 @@
if (base <= (mp_float_t)0.0) {
math_error();
} else if (base == (mp_float_t)1.0) {
- mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero");
+ mp_raise_msg(&mp_type_ZeroDivisionError, "divide by zero");
}
return mp_obj_new_float(l / MICROPY_FLOAT_C_FUN(log)(base));
}
diff --git a/py/obj.c b/py/obj.c
index a1de89a..5eb2b09 100644
--- a/py/obj.c
+++ b/py/obj.c
@@ -353,7 +353,7 @@
mp_raise_TypeError("expected tuple/list");
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
- "object '%s' is not a tuple or list", mp_obj_get_type_str(o)));
+ "object '%s' isn't a tuple or list", mp_obj_get_type_str(o)));
}
}
}
@@ -475,24 +475,24 @@
}
if (value == MP_OBJ_NULL) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
- mp_raise_TypeError("object does not support item deletion");
+ mp_raise_TypeError("object doesn't support item deletion");
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
- "'%s' object does not support item deletion", mp_obj_get_type_str(base)));
+ "'%s' object doesn't support item deletion", mp_obj_get_type_str(base)));
}
} else if (value == MP_OBJ_SENTINEL) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
- mp_raise_TypeError("object is not subscriptable");
+ mp_raise_TypeError("object isn't subscriptable");
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
- "'%s' object is not subscriptable", mp_obj_get_type_str(base)));
+ "'%s' object isn't subscriptable", mp_obj_get_type_str(base)));
}
} else {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
- mp_raise_TypeError("object does not support item assignment");
+ mp_raise_TypeError("object doesn't support item assignment");
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
- "'%s' object does not support item assignment", mp_obj_get_type_str(base)));
+ "'%s' object doesn't support item assignment", mp_obj_get_type_str(base)));
}
}
}
diff --git a/py/objcomplex.c b/py/objcomplex.c
index 409d656..42b396d 100644
--- a/py/objcomplex.c
+++ b/py/objcomplex.c
@@ -195,13 +195,13 @@
}
case MP_BINARY_OP_FLOOR_DIVIDE:
case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE:
- mp_raise_TypeError("can't do truncated division of a complex number");
+ mp_raise_TypeError("can't truncate-divide a complex number");
case MP_BINARY_OP_TRUE_DIVIDE:
case MP_BINARY_OP_INPLACE_TRUE_DIVIDE:
if (rhs_imag == 0) {
if (rhs_real == 0) {
- mp_raise_msg(&mp_type_ZeroDivisionError, "complex division by zero");
+ mp_raise_msg(&mp_type_ZeroDivisionError, "complex divide by zero");
}
lhs_real /= rhs_real;
lhs_imag /= rhs_real;
diff --git a/py/objfloat.c b/py/objfloat.c
index b62fe8e..2ea9947 100644
--- a/py/objfloat.c
+++ b/py/objfloat.c
@@ -262,7 +262,7 @@
case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE:
if (rhs_val == 0) {
zero_division_error:
- mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero");
+ mp_raise_msg(&mp_type_ZeroDivisionError, "divide by zero");
}
// Python specs require that x == (x//y)*y + (x%y) so we must
// call divmod to compute the correct floor division, which
diff --git a/py/objint_longlong.c b/py/objint_longlong.c
index cb8d167..485803c 100644
--- a/py/objint_longlong.c
+++ b/py/objint_longlong.c
@@ -217,7 +217,7 @@
}
zero_division:
- mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero");
+ mp_raise_msg(&mp_type_ZeroDivisionError, "divide by zero");
}
mp_obj_t mp_obj_new_int(mp_int_t value) {
diff --git a/py/objint_mpz.c b/py/objint_mpz.c
index 0f05c84..e59c123 100644
--- a/py/objint_mpz.c
+++ b/py/objint_mpz.c
@@ -225,7 +225,7 @@
case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE: {
if (mpz_is_zero(zrhs)) {
zero_division_error:
- mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero");
+ mp_raise_msg(&mp_type_ZeroDivisionError, "divide by zero");
}
mpz_t rem; mpz_init_zero(&rem);
mpz_divmod_inpl(&res->mpz, &rem, zlhs, zrhs);
diff --git a/py/objstr.c b/py/objstr.c
index d8c2bd1..397e5cc 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -1411,7 +1411,7 @@
// Dictionary value lookup
if (*str == '(') {
if (dict == MP_OBJ_NULL) {
- mp_raise_TypeError("format requires a dict");
+ mp_raise_TypeError("format needs a dict");
}
arg_i = 1; // we used up the single dict argument
const byte *key = ++str;
@@ -1486,7 +1486,7 @@
if (arg == MP_OBJ_NULL) {
if (arg_i >= n_args) {
not_enough_args:
- mp_raise_TypeError("not enough arguments for format string");
+ mp_raise_TypeError("format string needs more arguments");
}
arg = args[arg_i++];
}
@@ -1496,14 +1496,14 @@
size_t slen;
const char *s = mp_obj_str_get_data(arg, &slen);
if (slen != 1) {
- mp_raise_TypeError("%%c requires int or char");
+ mp_raise_TypeError("%%c needs int or char");
}
mp_print_strn(&print, s, 1, flags, ' ', width);
} else if (arg_looks_integer(arg)) {
char ch = mp_obj_get_int(arg);
mp_print_strn(&print, &ch, 1, flags, ' ', width);
} else {
- mp_raise_TypeError("integer required");
+ mp_raise_TypeError("integer needed");
}
break;
@@ -1573,7 +1573,7 @@
}
if (arg_i != n_args) {
- mp_raise_TypeError("not all arguments converted during string formatting");
+ mp_raise_TypeError("format string didn't convert all arguments");
}
return mp_obj_new_str_from_vstr(is_bytes ? &mp_type_bytes : &mp_type_str, &vstr);
diff --git a/py/objtype.c b/py/objtype.c
index 93c299d..67ba772 100644
--- a/py/objtype.c
+++ b/py/objtype.c
@@ -863,7 +863,7 @@
mp_raise_TypeError("object not callable");
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
- "'%s' object is not callable", mp_obj_get_type_str(self_in)));
+ "'%s' object isn't callable", mp_obj_get_type_str(self_in)));
}
}
mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in);
@@ -1090,10 +1090,10 @@
// TODO: Verify with CPy, tested on function type
if (t->make_new == NULL) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
- mp_raise_TypeError("type is not an acceptable base type");
+ mp_raise_TypeError("type isn't an acceptable base type");
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
- "type '%q' is not an acceptable base type", t->name));
+ "type '%q' isn't an acceptable base type", t->name));
}
}
#if ENABLE_SPECIAL_ACCESSORS
diff --git a/py/parse.c b/py/parse.c
index 8c12864..6c5ebbe 100644
--- a/py/parse.c
+++ b/py/parse.c
@@ -1145,7 +1145,7 @@
"unexpected indent");
} else if (lex->tok_kind == MP_TOKEN_DEDENT_MISMATCH) {
exc = mp_obj_new_exception_msg(&mp_type_IndentationError,
- "unindent does not match any outer indentation level");
+ "unindent doesn't match any outer indent level");
} else {
exc = mp_obj_new_exception_msg(&mp_type_SyntaxError,
"invalid syntax");
diff --git a/py/runtime.c b/py/runtime.c
index d58d95a..f987fc5 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -171,7 +171,7 @@
mp_raise_msg(&mp_type_NameError, "name not defined");
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_NameError,
- "name '%q' is not defined", qst));
+ "name '%q' isn't defined", qst));
}
}
}
@@ -581,7 +581,7 @@
}
zero_division:
- mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero");
+ mp_raise_msg(&mp_type_ZeroDivisionError, "divide by zero");
}
mp_obj_t mp_call_function_0(mp_obj_t fun) {
@@ -618,7 +618,7 @@
mp_raise_TypeError("object not callable");
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
- "'%s' object is not callable", mp_obj_get_type_str(fun_in)));
+ "'%s' object isn't callable", mp_obj_get_type_str(fun_in)));
}
}
@@ -1157,7 +1157,7 @@
mp_raise_TypeError("object not iterable");
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
- "'%s' object is not iterable", mp_obj_get_type_str(o_in)));
+ "'%s' object isn't iterable", mp_obj_get_type_str(o_in)));
}
}
@@ -1179,7 +1179,7 @@
mp_raise_TypeError("object not an iterator");
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
- "'%s' object is not an iterator", mp_obj_get_type_str(o_in)));
+ "'%s' object isn't an iterator", mp_obj_get_type_str(o_in)));
}
}
}
@@ -1215,7 +1215,7 @@
mp_raise_TypeError("object not an iterator");
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
- "'%s' object is not an iterator", mp_obj_get_type_str(o_in)));
+ "'%s' object isn't an iterator", mp_obj_get_type_str(o_in)));
}
}
}
diff --git a/tests/micropython/native_with.py.exp b/tests/micropython/native_with.py.exp
index 6eef782..7e28663 100644
--- a/tests/micropython/native_with.py.exp
+++ b/tests/micropython/native_with.py.exp
@@ -5,5 +5,5 @@
__init__
__enter__
1
-__exit__ <class 'NameError'> name 'fail' is not defined None
+__exit__ <class 'NameError'> name 'fail' isn't defined None
NameError
diff --git a/tests/micropython/opt_level.py.exp b/tests/micropython/opt_level.py.exp
index 9b1bb4d..6372f6c 100644
--- a/tests/micropython/opt_level.py.exp
+++ b/tests/micropython/opt_level.py.exp
@@ -4,4 +4,4 @@
False
Traceback (most recent call last):
File "<string>", line 1, in <module>
-NameError: name 'xyz' is not defined
+NameError: name 'xyz' isn't defined
diff --git a/tests/micropython/viper_with.py.exp b/tests/micropython/viper_with.py.exp
index 6eef782..7e28663 100644
--- a/tests/micropython/viper_with.py.exp
+++ b/tests/micropython/viper_with.py.exp
@@ -5,5 +5,5 @@
__init__
__enter__
1
-__exit__ <class 'NameError'> name 'fail' is not defined None
+__exit__ <class 'NameError'> name 'fail' isn't defined None
NameError
diff --git a/tests/misc/print_exception.py b/tests/misc/print_exception.py
index f331624..9543163 100644
--- a/tests/misc/print_exception.py
+++ b/tests/misc/print_exception.py
@@ -50,7 +50,7 @@
# Here we have a function with lots of bytecode generated for a single source-line, and
# there is an error right at the end of the bytecode. It should report the correct line.
def f():
- f([1, 2], [1, 2], [1, 2], {1:1, 1:1, 1:1, 1:1, 1:1, 1:1, 1:X})
+ f([1, 2], [1, 2], [1, 2], {1:1, 1:1, 1:1, 1:1, 1:1, 1:1, 1:f.X})
return 1
try:
f()