summaryrefslogtreecommitdiff
path: root/shared-bindings
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2020-08-01 12:14:55 -0500
committerJeff Epler <jepler@gmail.com>2020-08-04 13:34:29 -0500
commitdddd25a776fb0d9c002c1b6b039e24bb3048e6ff (patch)
tree72406398044fe8064b7e43fcd3c8e16f7a86b6f5 /shared-bindings
parentc394af412837f96164ebcc88d5301bece19e4a6f (diff)
Combine similar strings to reduce size of translations
This is a slight trade-off with code size, in places where a "_varg" mp_raise variant is now used. The net savings on trinket_m0 is just 32 bytes. It also means that the translation will include the original English text, and cannot be translated. These are usually names of Python types such as int, set, or dict or special values such as "inf" or "Nan".
Diffstat (limited to 'shared-bindings')
-rw-r--r--shared-bindings/i2cperipheral/I2CPeripheral.c2
-rw-r--r--shared-bindings/ps2io/Ps2.c2
-rw-r--r--shared-bindings/time/__init__.c2
3 files changed, 3 insertions, 3 deletions
diff --git a/shared-bindings/i2cperipheral/I2CPeripheral.c b/shared-bindings/i2cperipheral/I2CPeripheral.c
index cfebd472e..39f787062 100644
--- a/shared-bindings/i2cperipheral/I2CPeripheral.c
+++ b/shared-bindings/i2cperipheral/I2CPeripheral.c
@@ -86,7 +86,7 @@ STATIC mp_obj_t i2cperipheral_i2c_peripheral_make_new(const mp_obj_type_t *type,
while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
mp_int_t value;
if (!mp_obj_get_int_maybe(item, &value)) {
- mp_raise_TypeError(translate("can't convert address to int"));
+ mp_raise_TypeError_varg(translate("can't convert %s to %s"), "address", "int");
}
if (value < 0x00 || value > 0x7f) {
mp_raise_ValueError(translate("address out of bounds"));
diff --git a/shared-bindings/ps2io/Ps2.c b/shared-bindings/ps2io/Ps2.c
index 15731ea40..64d93f6ad 100644
--- a/shared-bindings/ps2io/Ps2.c
+++ b/shared-bindings/ps2io/Ps2.c
@@ -133,7 +133,7 @@ STATIC mp_obj_t ps2io_ps2_obj_popleft(mp_obj_t self_in) {
int b = common_hal_ps2io_ps2_popleft(self);
if (b < 0) {
- mp_raise_IndexError(translate("Pop from an empty Ps2 buffer"));
+ mp_raise_IndexError_varg(translate("pop from empty %s"), "Ps2 buffer");
}
return MP_OBJ_NEW_SMALL_INT(b);
}
diff --git a/shared-bindings/time/__init__.c b/shared-bindings/time/__init__.c
index 262da17fd..f7382b1ac 100644
--- a/shared-bindings/time/__init__.c
+++ b/shared-bindings/time/__init__.c
@@ -280,7 +280,7 @@ STATIC mp_obj_t time_mktime(mp_obj_t t) {
mp_obj_tuple_get(t, &len, &elem);
if (len != 9) {
- mp_raise_TypeError(translate("function takes exactly 9 arguments"));
+ mp_raise_TypeError_varg(translate("function takes %d positional arguments but %d were given"), 9);
}
if (mp_obj_get_int(elem[0]) < 2000) {