Two fixes and translate more strings.

* Fix finding translations with escaped characters.
* Add back \r to translations since its needed by screen.
This commit is contained in:
Scott Shawcroft 2018-08-08 18:24:49 -07:00
parent 9da79c880e
commit 96ebf5bc3f
No known key found for this signature in database
GPG Key ID: FD0EDC4B6C53CA59
49 changed files with 2207 additions and 335 deletions

View File

@ -40,6 +40,8 @@
#include "extmod/vfs_fat.h"
#include "lib/timeutils/timeutils.h"
#include "supervisor/shared/translate.h"
#if _MAX_SS == _MIN_SS
#define SECSIZE(fs) (_MIN_SS)
#else
@ -421,7 +423,7 @@ STATIC mp_obj_t vfs_fat_setlabel(mp_obj_t self_in, mp_obj_t label_in) {
FRESULT res = f_setlabel(&self->fatfs, label_str);
if (res != FR_OK) {
if(res == FR_WRITE_PROTECTED) {
mp_raise_msg(&mp_type_OSError, "Read-only filesystem");
mp_raise_msg(&mp_type_OSError, translate("Read-only filesystem"));
}
mp_raise_OSError(fresult_to_errno_table[res]);
}

View File

@ -1,7 +1,9 @@
#include <py/runtime.h>
#include "supervisor/shared/translate.h"
NORETURN void abort_(void);
NORETURN void abort_(void) {
mp_raise_msg(&mp_type_RuntimeError, "abort() called");
mp_raise_msg(&mp_type_RuntimeError, translate("abort() called"));
}

View File

@ -94,7 +94,7 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input
// Clear the parse tree because it has a heap pointer we don't need anymore.
*((uint32_t volatile*) &parse_tree.chunk) = 0;
#else
mp_raise_msg(&mp_type_RuntimeError, "script compilation not supported");
mp_raise_msg(&mp_type_RuntimeError, translate("script compilation not supported"));
#endif
}

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-08-03 17:20-0700\n"
"POT-Creation-Date: 2018-08-08 15:15-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -185,7 +185,7 @@ msgid "Not enough pins available"
msgstr ""
#: ports/atmel-samd/common-hal/busio/I2C.c:76
#: ports/atmel-samd/common-hal/busio/UART.c:121
#: ports/atmel-samd/common-hal/busio/UART.c:119
msgid "Invalid pins"
msgstr ""
@ -201,23 +201,23 @@ msgstr ""
msgid "bytes > 8 bits not supported"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c:73
#: ports/atmel-samd/common-hal/busio/UART.c:72
msgid "tx and rx cannot both be None"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c:142
#: ports/atmel-samd/common-hal/busio/UART.c:139
msgid "Failed to allocate RX buffer"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c:151
#: ports/atmel-samd/common-hal/busio/UART.c:147
msgid "Could not initialize UART"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c:239
#: ports/atmel-samd/common-hal/busio/UART.c:234
msgid "No RX pin"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c:289
#: ports/atmel-samd/common-hal/busio/UART.c:284
msgid "No TX pin"
msgstr ""
@ -296,6 +296,151 @@ msgstr ""
msgid "USB Error"
msgstr ""
#: py/compile.c:397 py/compile.c:542
msgid "can't assign to expression"
msgstr ""
#: py/compile.c:416
msgid "multiple *x in assignment"
msgstr ""
#: py/compile.c:642
msgid "non-default argument follows default argument"
msgstr ""
#: py/compile.c:771 py/compile.c:789
msgid "invalid micropython decorator"
msgstr ""
#: py/compile.c:943
msgid "can't delete expression"
msgstr ""
#: py/compile.c:955
msgid "'break' outside loop"
msgstr ""
#: py/compile.c:958
msgid "'continue' outside loop"
msgstr ""
#: py/compile.c:969
msgid "'return' outside function"
msgstr ""
#: py/compile.c:1169
msgid "identifier redefined as global"
msgstr ""
#: py/compile.c:1185
msgid "no binding for nonlocal found"
msgstr ""
#: py/compile.c:1188
msgid "identifier redefined as nonlocal"
msgstr ""
#: py/compile.c:1197
msgid "can't declare nonlocal in outer code"
msgstr ""
#: py/compile.c:1542
msgid "default 'except' must be last"
msgstr ""
#: py/compile.c:2095
msgid "*x must be assignment target"
msgstr ""
#: py/compile.c:2193
msgid "super() can't find self"
msgstr ""
#: py/compile.c:2256
msgid "can't have multiple *x"
msgstr ""
#: py/compile.c:2263
msgid "can't have multiple **x"
msgstr ""
#: py/compile.c:2271
msgid "LHS of keyword arg must be an id"
msgstr ""
#: py/compile.c:2287
msgid "non-keyword arg after */**"
msgstr ""
#: py/compile.c:2291
msgid "non-keyword arg after keyword arg"
msgstr ""
#: py/compile.c:2463 py/compile.c:2473 py/compile.c:2712 py/compile.c:2742
#: py/parse.c:1176
msgid "invalid syntax"
msgstr ""
#: py/compile.c:2465
msgid "expecting key:value for dict"
msgstr ""
#: py/compile.c:2475
msgid "expecting just a value for set"
msgstr ""
#: py/compile.c:2600
msgid "'yield' outside function"
msgstr ""
#: py/compile.c:2619
msgid "'await' outside function"
msgstr ""
#: py/compile.c:2774
msgid "name reused for argument"
msgstr ""
#: py/compile.c:2827
msgid "parameter annotation must be an identifier"
msgstr ""
#: py/compile.c:2969 py/compile.c:3137
msgid "return annotation must be an identifier"
msgstr ""
#: py/compile.c:3097
msgid "inline assembler must be a function"
msgstr ""
#: py/compile.c:3134
msgid "unknown type"
msgstr ""
#: py/compile.c:3154
msgid "expecting an assembler instruction"
msgstr ""
#: py/compile.c:3184
msgid "'label' requires 1 argument"
msgstr ""
#: py/compile.c:3190
msgid "label redefined"
msgstr ""
#: py/compile.c:3196
msgid "'align' requires 1 argument"
msgstr ""
#: py/compile.c:3205
msgid "'data' requires at least 2 arguments"
msgstr ""
#: py/compile.c:3212
msgid "'data' requires integer arguments"
msgstr ""
#: py/modbuiltins.c:162
msgid "chr() arg not in range(0x110000)"
msgstr ""
@ -331,6 +476,462 @@ msgstr ""
msgid "buffer too small"
msgstr ""
#: py/obj.c:89
msgid "Traceback (most recent call last):\n"
msgstr ""
#: py/obj.c:92
msgid " File \"%q\", line %d"
msgstr ""
#: py/obj.c:94
msgid " File \"%q\""
msgstr ""
#: py/obj.c:101
msgid ", in %q\n"
msgstr ""
#: py/objint_mpz.c:230 py/runtime.c:619 shared-bindings/math/__init__.c:346
msgid "division by zero"
msgstr ""
#: py/objint_mpz.c:267 py/runtime.c:396 py/runtime.c:411
msgid "negative shift count"
msgstr ""
#: py/objint_mpz.c:283 py/runtime.c:486
msgid "negative power with no float support"
msgstr ""
#: py/objint_mpz.c:336
msgid "pow() with 3 arguments requires integers"
msgstr ""
#: py/objint_mpz.c:347
msgid "pow() 3rd argument cannot be 0"
msgstr ""
#: py/objint_mpz.c:415
msgid "overflow converting long int to machine word"
msgstr ""
#: py/objlist.c:273
msgid "pop from empty list"
msgstr ""
#: py/objnamedtuple.c:92
msgid "can't set attribute"
msgstr ""
#: py/objnamedtuple.c:104
#, c-format
msgid "function takes %d positional arguments but %d were given"
msgstr ""
#: py/objnamedtuple.c:108
msgid "%q() takes %d positional arguments but %d were given"
msgstr ""
#: py/objnamedtuple.c:130
msgid "unexpected keyword argument '%q'"
msgstr ""
#: py/objnamedtuple.c:138
msgid "function got multiple values for argument '%q'"
msgstr ""
#: py/objobject.c:55
msgid "__new__ arg must be a user-type"
msgstr ""
#: py/objrange.c:110
msgid "zero step"
msgstr ""
#: py/objset.c:371
msgid "pop from an empty set"
msgstr ""
#: py/objslice.c:66
msgid "Length must be an int"
msgstr ""
#: py/objslice.c:71
msgid "Length must be non-negative"
msgstr ""
#: py/objslice.c:86 py/sequence.c:57
msgid "slice step cannot be zero"
msgstr ""
#: py/objslice.c:159
msgid "Cannot subclass slice"
msgstr ""
#: py/objstr.c:261
msgid "bytes value out of range"
msgstr ""
#: py/objstr.c:270
msgid "wrong number of arguments"
msgstr ""
#: py/objstr.c:427 py/objstrunicode.c:191 py/objtuple.c:187
#: shared-bindings/nvm/ByteArray.c:85
msgid "only slices with step=1 (aka None) are supported"
msgstr ""
#: py/objstr.c:467
msgid "join expects a list of str/bytes objects consistent with self object"
msgstr ""
#: py/objstr.c:542 py/objstr.c:647 py/objstr.c:1744
msgid "empty separator"
msgstr ""
#: py/objstr.c:641
msgid "rsplit(None,n)"
msgstr ""
#: py/objstr.c:713
msgid "substring not found"
msgstr ""
#: py/objstr.c:770
msgid "start/end indices"
msgstr ""
#: py/objstr.c:931
msgid "bad format string"
msgstr ""
#: py/objstr.c:953
msgid "single '}' encountered in format string"
msgstr ""
#: py/objstr.c:992
msgid "bad conversion specifier"
msgstr ""
#: py/objstr.c:996
msgid "end of format while looking for conversion specifier"
msgstr ""
#: py/objstr.c:998
#, c-format
msgid "unknown conversion specifier %c"
msgstr ""
#: py/objstr.c:1029
msgid "unmatched '{' in format"
msgstr ""
#: py/objstr.c:1036
msgid "expected ':' after format specifier"
msgstr ""
#: py/objstr.c:1050
msgid ""
"can't switch from automatic field numbering to manual field specification"
msgstr ""
#: py/objstr.c:1055 py/objstr.c:1083
msgid "tuple index out of range"
msgstr ""
#: py/objstr.c:1071
msgid "attributes not supported yet"
msgstr ""
#: py/objstr.c:1079
msgid ""
"can't switch from manual field specification to automatic field numbering"
msgstr ""
#: py/objstr.c:1171
msgid "invalid format specifier"
msgstr ""
#: py/objstr.c:1192
msgid "sign not allowed in string format specifier"
msgstr ""
#: py/objstr.c:1200
msgid "sign not allowed with integer format specifier 'c'"
msgstr ""
#: py/objstr.c:1259
#, c-format
msgid "unknown format code '%c' for object of type '%s'"
msgstr ""
#: py/objstr.c:1331
#, c-format
msgid "unknown format code '%c' for object of type 'float'"
msgstr ""
#: py/objstr.c:1343
msgid "'=' alignment not allowed in string format specifier"
msgstr ""
#: py/objstr.c:1367
#, c-format
msgid "unknown format code '%c' for object of type 'str'"
msgstr ""
#: py/objstr.c:1415
msgid "format requires a dict"
msgstr ""
#: py/objstr.c:1424
msgid "incomplete format key"
msgstr ""
#: py/objstr.c:1482
msgid "incomplete format"
msgstr ""
#: py/objstr.c:1490
msgid "not enough arguments for format string"
msgstr ""
#: py/objstr.c:1500
#, c-format
msgid "%%c requires int or char"
msgstr ""
#: py/objstr.c:1507
msgid "integer required"
msgstr ""
#: py/objstr.c:1570
#, c-format
msgid "unsupported format character '%c' (0x%x) at index %d"
msgstr ""
#: py/objstr.c:1577
msgid "not all arguments converted during string formatting"
msgstr ""
#: py/objstr.c:2102
msgid "can't convert to str implicitly"
msgstr ""
#: py/objstr.c:2106
msgid "can't convert '%q' object to %q implicitly"
msgstr ""
#: py/objstringio.c:43
msgid "I/O operation on closed file"
msgstr ""
#: py/objstrunicode.c:134
#, c-format
msgid "string indices must be integers, not %s"
msgstr ""
#: py/objstrunicode.c:145 py/objstrunicode.c:164
msgid "string index out of range"
msgstr ""
#: py/objtype.c:358
msgid "__init__() should return None"
msgstr ""
#: py/objtype.c:360
#, c-format
msgid "__init__() should return None, not '%s'"
msgstr ""
#: py/objtype.c:623 py/objtype.c:1275 py/runtime.c:1065
msgid "unreadable attribute"
msgstr ""
#: py/objtype.c:868 py/runtime.c:653
msgid "object not callable"
msgstr ""
#: py/objtype.c:870 py/runtime.c:655
#, c-format
msgid "'%s' object is not callable"
msgstr ""
#: py/objtype.c:978
msgid "type takes 1 or 3 arguments"
msgstr ""
#: py/objtype.c:989
msgid "cannot create instance"
msgstr ""
#: py/objtype.c:991
msgid "cannot create '%q' instances"
msgstr ""
#: py/objtype.c:1047
msgid "can't add special method to already-subclassed class"
msgstr ""
#: py/objtype.c:1091 py/objtype.c:1097
msgid "type is not an acceptable base type"
msgstr ""
#: py/objtype.c:1100
msgid "type '%q' is not an acceptable base type"
msgstr ""
#: py/objtype.c:1137
msgid "multiple inheritance not supported"
msgstr ""
#: py/objtype.c:1164
msgid "multiple bases have instance lay-out conflict"
msgstr ""
#: py/objtype.c:1205
msgid "first argument to super() must be type"
msgstr ""
#: py/objtype.c:1370
msgid "issubclass() arg 2 must be a class or a tuple of classes"
msgstr ""
#: py/objtype.c:1384
msgid "issubclass() arg 1 must be a class"
msgstr ""
#: py/parse.c:726
msgid "constant must be an integer"
msgstr ""
#: py/parse.c:868
msgid "Unable to init parser"
msgstr ""
#: py/parse.c:1170
msgid "unexpected indent"
msgstr ""
#: py/parse.c:1173
msgid "unindent does not match any outer indentation level"
msgstr ""
#: py/parsenum.c:60
msgid "int() arg 2 must be >= 2 and <= 36"
msgstr ""
#: py/persistentcode.c:223
msgid ""
"Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/"
"mpy-update for more info."
msgstr ""
#: py/persistentcode.c:326
msgid "can only save bytecode"
msgstr ""
#: py/runtime.c:206
msgid "name not defined"
msgstr ""
#: py/runtime.c:209
msgid "name '%q' is not defined"
msgstr ""
#: py/runtime.c:304 py/runtime.c:611
msgid "unsupported type for operator"
msgstr ""
#: py/runtime.c:307
msgid "unsupported type for %q: '%s'"
msgstr ""
#: py/runtime.c:614
msgid "unsupported types for %q: '%s', '%s'"
msgstr ""
#: py/runtime.c:881 py/runtime.c:888 py/runtime.c:945
msgid "wrong number of values to unpack"
msgstr ""
#: py/runtime.c:883 py/runtime.c:947
#, c-format
msgid "need more than %d values to unpack"
msgstr ""
#: py/runtime.c:890
#, c-format
msgid "too many values to unpack (expected %d)"
msgstr ""
#: py/runtime.c:984
msgid "argument has wrong type"
msgstr ""
#: py/runtime.c:986
msgid "argument should be a '%q' not a '%q'"
msgstr ""
#: py/runtime.c:1123 py/runtime.c:1197
msgid "no such attribute"
msgstr ""
#: py/runtime.c:1128
msgid "type object '%q' has no attribute '%q'"
msgstr ""
#: py/runtime.c:1132 py/runtime.c:1200
msgid "'%s' object has no attribute '%q'"
msgstr ""
#: py/runtime.c:1238
msgid "object not iterable"
msgstr ""
#: py/runtime.c:1241
#, c-format
msgid "'%s' object is not iterable"
msgstr ""
#: py/runtime.c:1260 py/runtime.c:1296
msgid "object not an iterator"
msgstr ""
#: py/runtime.c:1262 py/runtime.c:1298
#, c-format
msgid "'%s' object is not an iterator"
msgstr ""
#: py/runtime.c:1401
msgid "exceptions must derive from BaseException"
msgstr ""
#: py/runtime.c:1430
msgid "cannot import name %q"
msgstr ""
#: py/runtime.c:1535
msgid "memory allocation failed, heap is locked"
msgstr ""
#: py/runtime.c:1539
#, c-format
msgid "memory allocation failed, allocating %u bytes"
msgstr ""
#: py/runtime.c:1609
msgid "maximum recursion depth exceeded"
msgstr ""
#: py/sequence.c:264
msgid "object not in sequence"
msgstr ""
#: py/stream.c:96
msgid "stream operation not supported"
msgstr ""
#: shared-bindings/_stage/Layer.c:71
msgid "graphic must be 2048 bytes long"
msgstr ""
@ -474,16 +1075,16 @@ msgstr ""
msgid "math domain error"
msgstr ""
#: shared-bindings/math/__init__.c:346
msgid "division by zero"
msgstr ""
#: shared-bindings/microcontroller/Pin.c:89
#: shared-bindings/neopixel_write/__init__.c:67
#: shared-bindings/pulseio/PulseOut.c:75
msgid "Expected a %q"
msgstr ""
#: shared-bindings/microcontroller/Pin.c:100
msgid "%q in use"
msgstr ""
#: shared-bindings/microcontroller/__init__.c:126
msgid "Invalid run mode."
msgstr ""
@ -492,10 +1093,6 @@ msgstr ""
msgid "Stream missing readinto() or write() method."
msgstr ""
#: shared-bindings/nvm/ByteArray.c:85
msgid "only slices with step=1 (aka None) are supported"
msgstr ""
#: shared-bindings/nvm/ByteArray.c:99
msgid "Slice and value different lengths."
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-08-03 17:20-0700\n"
"POT-Creation-Date: 2018-08-08 15:15-0700\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -185,7 +185,7 @@ msgid "Not enough pins available"
msgstr ""
#: ports/atmel-samd/common-hal/busio/I2C.c:76
#: ports/atmel-samd/common-hal/busio/UART.c:121
#: ports/atmel-samd/common-hal/busio/UART.c:119
msgid "Invalid pins"
msgstr ""
@ -201,23 +201,23 @@ msgstr ""
msgid "bytes > 8 bits not supported"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c:73
#: ports/atmel-samd/common-hal/busio/UART.c:72
msgid "tx and rx cannot both be None"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c:142
#: ports/atmel-samd/common-hal/busio/UART.c:139
msgid "Failed to allocate RX buffer"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c:151
#: ports/atmel-samd/common-hal/busio/UART.c:147
msgid "Could not initialize UART"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c:239
#: ports/atmel-samd/common-hal/busio/UART.c:234
msgid "No RX pin"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c:289
#: ports/atmel-samd/common-hal/busio/UART.c:284
msgid "No TX pin"
msgstr ""
@ -296,6 +296,151 @@ msgstr ""
msgid "USB Error"
msgstr ""
#: py/compile.c:397 py/compile.c:542
msgid "can't assign to expression"
msgstr ""
#: py/compile.c:416
msgid "multiple *x in assignment"
msgstr ""
#: py/compile.c:642
msgid "non-default argument follows default argument"
msgstr ""
#: py/compile.c:771 py/compile.c:789
msgid "invalid micropython decorator"
msgstr ""
#: py/compile.c:943
msgid "can't delete expression"
msgstr ""
#: py/compile.c:955
msgid "'break' outside loop"
msgstr ""
#: py/compile.c:958
msgid "'continue' outside loop"
msgstr ""
#: py/compile.c:969
msgid "'return' outside function"
msgstr ""
#: py/compile.c:1169
msgid "identifier redefined as global"
msgstr ""
#: py/compile.c:1185
msgid "no binding for nonlocal found"
msgstr ""
#: py/compile.c:1188
msgid "identifier redefined as nonlocal"
msgstr ""
#: py/compile.c:1197
msgid "can't declare nonlocal in outer code"
msgstr ""
#: py/compile.c:1542
msgid "default 'except' must be last"
msgstr ""
#: py/compile.c:2095
msgid "*x must be assignment target"
msgstr ""
#: py/compile.c:2193
msgid "super() can't find self"
msgstr ""
#: py/compile.c:2256
msgid "can't have multiple *x"
msgstr ""
#: py/compile.c:2263
msgid "can't have multiple **x"
msgstr ""
#: py/compile.c:2271
msgid "LHS of keyword arg must be an id"
msgstr ""
#: py/compile.c:2287
msgid "non-keyword arg after */**"
msgstr ""
#: py/compile.c:2291
msgid "non-keyword arg after keyword arg"
msgstr ""
#: py/compile.c:2463 py/compile.c:2473 py/compile.c:2712 py/compile.c:2742
#: py/parse.c:1176
msgid "invalid syntax"
msgstr ""
#: py/compile.c:2465
msgid "expecting key:value for dict"
msgstr ""
#: py/compile.c:2475
msgid "expecting just a value for set"
msgstr ""
#: py/compile.c:2600
msgid "'yield' outside function"
msgstr ""
#: py/compile.c:2619
msgid "'await' outside function"
msgstr ""
#: py/compile.c:2774
msgid "name reused for argument"
msgstr ""
#: py/compile.c:2827
msgid "parameter annotation must be an identifier"
msgstr ""
#: py/compile.c:2969 py/compile.c:3137
msgid "return annotation must be an identifier"
msgstr ""
#: py/compile.c:3097
msgid "inline assembler must be a function"
msgstr ""
#: py/compile.c:3134
msgid "unknown type"
msgstr ""
#: py/compile.c:3154
msgid "expecting an assembler instruction"
msgstr ""
#: py/compile.c:3184
msgid "'label' requires 1 argument"
msgstr ""
#: py/compile.c:3190
msgid "label redefined"
msgstr ""
#: py/compile.c:3196
msgid "'align' requires 1 argument"
msgstr ""
#: py/compile.c:3205
msgid "'data' requires at least 2 arguments"
msgstr ""
#: py/compile.c:3212
msgid "'data' requires integer arguments"
msgstr ""
#: py/modbuiltins.c:162
msgid "chr() arg not in range(0x110000)"
msgstr ""
@ -331,6 +476,462 @@ msgstr ""
msgid "buffer too small"
msgstr ""
#: py/obj.c:89
msgid "Traceback (most recent call last):\n"
msgstr ""
#: py/obj.c:92
msgid " File \"%q\", line %d"
msgstr ""
#: py/obj.c:94
msgid " File \"%q\""
msgstr ""
#: py/obj.c:101
msgid ", in %q\n"
msgstr ""
#: py/objint_mpz.c:230 py/runtime.c:619 shared-bindings/math/__init__.c:346
msgid "division by zero"
msgstr ""
#: py/objint_mpz.c:267 py/runtime.c:396 py/runtime.c:411
msgid "negative shift count"
msgstr ""
#: py/objint_mpz.c:283 py/runtime.c:486
msgid "negative power with no float support"
msgstr ""
#: py/objint_mpz.c:336
msgid "pow() with 3 arguments requires integers"
msgstr ""
#: py/objint_mpz.c:347
msgid "pow() 3rd argument cannot be 0"
msgstr ""
#: py/objint_mpz.c:415
msgid "overflow converting long int to machine word"
msgstr ""
#: py/objlist.c:273
msgid "pop from empty list"
msgstr ""
#: py/objnamedtuple.c:92
msgid "can't set attribute"
msgstr ""
#: py/objnamedtuple.c:104
#, c-format
msgid "function takes %d positional arguments but %d were given"
msgstr ""
#: py/objnamedtuple.c:108
msgid "%q() takes %d positional arguments but %d were given"
msgstr ""
#: py/objnamedtuple.c:130
msgid "unexpected keyword argument '%q'"
msgstr ""
#: py/objnamedtuple.c:138
msgid "function got multiple values for argument '%q'"
msgstr ""
#: py/objobject.c:55
msgid "__new__ arg must be a user-type"
msgstr ""
#: py/objrange.c:110
msgid "zero step"
msgstr ""
#: py/objset.c:371
msgid "pop from an empty set"
msgstr ""
#: py/objslice.c:66
msgid "Length must be an int"
msgstr ""
#: py/objslice.c:71
msgid "Length must be non-negative"
msgstr ""
#: py/objslice.c:86 py/sequence.c:57
msgid "slice step cannot be zero"
msgstr ""
#: py/objslice.c:159
msgid "Cannot subclass slice"
msgstr ""
#: py/objstr.c:261
msgid "bytes value out of range"
msgstr ""
#: py/objstr.c:270
msgid "wrong number of arguments"
msgstr ""
#: py/objstr.c:427 py/objstrunicode.c:191 py/objtuple.c:187
#: shared-bindings/nvm/ByteArray.c:85
msgid "only slices with step=1 (aka None) are supported"
msgstr ""
#: py/objstr.c:467
msgid "join expects a list of str/bytes objects consistent with self object"
msgstr ""
#: py/objstr.c:542 py/objstr.c:647 py/objstr.c:1744
msgid "empty separator"
msgstr ""
#: py/objstr.c:641
msgid "rsplit(None,n)"
msgstr ""
#: py/objstr.c:713
msgid "substring not found"
msgstr ""
#: py/objstr.c:770
msgid "start/end indices"
msgstr ""
#: py/objstr.c:931
msgid "bad format string"
msgstr ""
#: py/objstr.c:953
msgid "single '}' encountered in format string"
msgstr ""
#: py/objstr.c:992
msgid "bad conversion specifier"
msgstr ""
#: py/objstr.c:996
msgid "end of format while looking for conversion specifier"
msgstr ""
#: py/objstr.c:998
#, c-format
msgid "unknown conversion specifier %c"
msgstr ""
#: py/objstr.c:1029
msgid "unmatched '{' in format"
msgstr ""
#: py/objstr.c:1036
msgid "expected ':' after format specifier"
msgstr ""
#: py/objstr.c:1050
msgid ""
"can't switch from automatic field numbering to manual field specification"
msgstr ""
#: py/objstr.c:1055 py/objstr.c:1083
msgid "tuple index out of range"
msgstr ""
#: py/objstr.c:1071
msgid "attributes not supported yet"
msgstr ""
#: py/objstr.c:1079
msgid ""
"can't switch from manual field specification to automatic field numbering"
msgstr ""
#: py/objstr.c:1171
msgid "invalid format specifier"
msgstr ""
#: py/objstr.c:1192
msgid "sign not allowed in string format specifier"
msgstr ""
#: py/objstr.c:1200
msgid "sign not allowed with integer format specifier 'c'"
msgstr ""
#: py/objstr.c:1259
#, c-format
msgid "unknown format code '%c' for object of type '%s'"
msgstr ""
#: py/objstr.c:1331
#, c-format
msgid "unknown format code '%c' for object of type 'float'"
msgstr ""
#: py/objstr.c:1343
msgid "'=' alignment not allowed in string format specifier"
msgstr ""
#: py/objstr.c:1367
#, c-format
msgid "unknown format code '%c' for object of type 'str'"
msgstr ""
#: py/objstr.c:1415
msgid "format requires a dict"
msgstr ""
#: py/objstr.c:1424
msgid "incomplete format key"
msgstr ""
#: py/objstr.c:1482
msgid "incomplete format"
msgstr ""
#: py/objstr.c:1490
msgid "not enough arguments for format string"
msgstr ""
#: py/objstr.c:1500
#, c-format
msgid "%%c requires int or char"
msgstr ""
#: py/objstr.c:1507
msgid "integer required"
msgstr ""
#: py/objstr.c:1570
#, c-format
msgid "unsupported format character '%c' (0x%x) at index %d"
msgstr ""
#: py/objstr.c:1577
msgid "not all arguments converted during string formatting"
msgstr ""
#: py/objstr.c:2102
msgid "can't convert to str implicitly"
msgstr ""
#: py/objstr.c:2106
msgid "can't convert '%q' object to %q implicitly"
msgstr ""
#: py/objstringio.c:43
msgid "I/O operation on closed file"
msgstr ""
#: py/objstrunicode.c:134
#, c-format
msgid "string indices must be integers, not %s"
msgstr ""
#: py/objstrunicode.c:145 py/objstrunicode.c:164
msgid "string index out of range"
msgstr ""
#: py/objtype.c:358
msgid "__init__() should return None"
msgstr ""
#: py/objtype.c:360
#, c-format
msgid "__init__() should return None, not '%s'"
msgstr ""
#: py/objtype.c:623 py/objtype.c:1275 py/runtime.c:1065
msgid "unreadable attribute"
msgstr ""
#: py/objtype.c:868 py/runtime.c:653
msgid "object not callable"
msgstr ""
#: py/objtype.c:870 py/runtime.c:655
#, c-format
msgid "'%s' object is not callable"
msgstr ""
#: py/objtype.c:978
msgid "type takes 1 or 3 arguments"
msgstr ""
#: py/objtype.c:989
msgid "cannot create instance"
msgstr ""
#: py/objtype.c:991
msgid "cannot create '%q' instances"
msgstr ""
#: py/objtype.c:1047
msgid "can't add special method to already-subclassed class"
msgstr ""
#: py/objtype.c:1091 py/objtype.c:1097
msgid "type is not an acceptable base type"
msgstr ""
#: py/objtype.c:1100
msgid "type '%q' is not an acceptable base type"
msgstr ""
#: py/objtype.c:1137
msgid "multiple inheritance not supported"
msgstr ""
#: py/objtype.c:1164
msgid "multiple bases have instance lay-out conflict"
msgstr ""
#: py/objtype.c:1205
msgid "first argument to super() must be type"
msgstr ""
#: py/objtype.c:1370
msgid "issubclass() arg 2 must be a class or a tuple of classes"
msgstr ""
#: py/objtype.c:1384
msgid "issubclass() arg 1 must be a class"
msgstr ""
#: py/parse.c:726
msgid "constant must be an integer"
msgstr ""
#: py/parse.c:868
msgid "Unable to init parser"
msgstr ""
#: py/parse.c:1170
msgid "unexpected indent"
msgstr ""
#: py/parse.c:1173
msgid "unindent does not match any outer indentation level"
msgstr ""
#: py/parsenum.c:60
msgid "int() arg 2 must be >= 2 and <= 36"
msgstr ""
#: py/persistentcode.c:223
msgid ""
"Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/"
"mpy-update for more info."
msgstr ""
#: py/persistentcode.c:326
msgid "can only save bytecode"
msgstr ""
#: py/runtime.c:206
msgid "name not defined"
msgstr ""
#: py/runtime.c:209
msgid "name '%q' is not defined"
msgstr ""
#: py/runtime.c:304 py/runtime.c:611
msgid "unsupported type for operator"
msgstr ""
#: py/runtime.c:307
msgid "unsupported type for %q: '%s'"
msgstr ""
#: py/runtime.c:614
msgid "unsupported types for %q: '%s', '%s'"
msgstr ""
#: py/runtime.c:881 py/runtime.c:888 py/runtime.c:945
msgid "wrong number of values to unpack"
msgstr ""
#: py/runtime.c:883 py/runtime.c:947
#, c-format
msgid "need more than %d values to unpack"
msgstr ""
#: py/runtime.c:890
#, c-format
msgid "too many values to unpack (expected %d)"
msgstr ""
#: py/runtime.c:984
msgid "argument has wrong type"
msgstr ""
#: py/runtime.c:986
msgid "argument should be a '%q' not a '%q'"
msgstr ""
#: py/runtime.c:1123 py/runtime.c:1197
msgid "no such attribute"
msgstr ""
#: py/runtime.c:1128
msgid "type object '%q' has no attribute '%q'"
msgstr ""
#: py/runtime.c:1132 py/runtime.c:1200
msgid "'%s' object has no attribute '%q'"
msgstr ""
#: py/runtime.c:1238
msgid "object not iterable"
msgstr ""
#: py/runtime.c:1241
#, c-format
msgid "'%s' object is not iterable"
msgstr ""
#: py/runtime.c:1260 py/runtime.c:1296
msgid "object not an iterator"
msgstr ""
#: py/runtime.c:1262 py/runtime.c:1298
#, c-format
msgid "'%s' object is not an iterator"
msgstr ""
#: py/runtime.c:1401
msgid "exceptions must derive from BaseException"
msgstr ""
#: py/runtime.c:1430
msgid "cannot import name %q"
msgstr ""
#: py/runtime.c:1535
msgid "memory allocation failed, heap is locked"
msgstr ""
#: py/runtime.c:1539
#, c-format
msgid "memory allocation failed, allocating %u bytes"
msgstr ""
#: py/runtime.c:1609
msgid "maximum recursion depth exceeded"
msgstr ""
#: py/sequence.c:264
msgid "object not in sequence"
msgstr ""
#: py/stream.c:96
msgid "stream operation not supported"
msgstr ""
#: shared-bindings/_stage/Layer.c:71
msgid "graphic must be 2048 bytes long"
msgstr ""
@ -474,16 +1075,16 @@ msgstr ""
msgid "math domain error"
msgstr ""
#: shared-bindings/math/__init__.c:346
msgid "division by zero"
msgstr ""
#: shared-bindings/microcontroller/Pin.c:89
#: shared-bindings/neopixel_write/__init__.c:67
#: shared-bindings/pulseio/PulseOut.c:75
msgid "Expected a %q"
msgstr ""
#: shared-bindings/microcontroller/Pin.c:100
msgid "%q in use"
msgstr ""
#: shared-bindings/microcontroller/__init__.c:126
msgid "Invalid run mode."
msgstr ""
@ -492,10 +1093,6 @@ msgstr ""
msgid "Stream missing readinto() or write() method."
msgstr ""
#: shared-bindings/nvm/ByteArray.c:85
msgid "only slices with step=1 (aka None) are supported"
msgstr ""
#: shared-bindings/nvm/ByteArray.c:99
msgid "Slice and value different lengths."
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-08-03 17:20-0700\n"
"POT-Creation-Date: 2018-08-08 15:15-0700\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -185,7 +185,7 @@ msgid "Not enough pins available"
msgstr ""
#: ports/atmel-samd/common-hal/busio/I2C.c:76
#: ports/atmel-samd/common-hal/busio/UART.c:121
#: ports/atmel-samd/common-hal/busio/UART.c:119
msgid "Invalid pins"
msgstr ""
@ -201,23 +201,23 @@ msgstr ""
msgid "bytes > 8 bits not supported"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c:73
#: ports/atmel-samd/common-hal/busio/UART.c:72
msgid "tx and rx cannot both be None"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c:142
#: ports/atmel-samd/common-hal/busio/UART.c:139
msgid "Failed to allocate RX buffer"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c:151
#: ports/atmel-samd/common-hal/busio/UART.c:147
msgid "Could not initialize UART"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c:239
#: ports/atmel-samd/common-hal/busio/UART.c:234
msgid "No RX pin"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c:289
#: ports/atmel-samd/common-hal/busio/UART.c:284
msgid "No TX pin"
msgstr ""
@ -296,6 +296,151 @@ msgstr ""
msgid "USB Error"
msgstr ""
#: py/compile.c:397 py/compile.c:542
msgid "can't assign to expression"
msgstr ""
#: py/compile.c:416
msgid "multiple *x in assignment"
msgstr ""
#: py/compile.c:642
msgid "non-default argument follows default argument"
msgstr ""
#: py/compile.c:771 py/compile.c:789
msgid "invalid micropython decorator"
msgstr ""
#: py/compile.c:943
msgid "can't delete expression"
msgstr ""
#: py/compile.c:955
msgid "'break' outside loop"
msgstr ""
#: py/compile.c:958
msgid "'continue' outside loop"
msgstr ""
#: py/compile.c:969
msgid "'return' outside function"
msgstr ""
#: py/compile.c:1169
msgid "identifier redefined as global"
msgstr ""
#: py/compile.c:1185
msgid "no binding for nonlocal found"
msgstr ""
#: py/compile.c:1188
msgid "identifier redefined as nonlocal"
msgstr ""
#: py/compile.c:1197
msgid "can't declare nonlocal in outer code"
msgstr ""
#: py/compile.c:1542
msgid "default 'except' must be last"
msgstr ""
#: py/compile.c:2095
msgid "*x must be assignment target"
msgstr ""
#: py/compile.c:2193
msgid "super() can't find self"
msgstr ""
#: py/compile.c:2256
msgid "can't have multiple *x"
msgstr ""
#: py/compile.c:2263
msgid "can't have multiple **x"
msgstr ""
#: py/compile.c:2271
msgid "LHS of keyword arg must be an id"
msgstr ""
#: py/compile.c:2287
msgid "non-keyword arg after */**"
msgstr ""
#: py/compile.c:2291
msgid "non-keyword arg after keyword arg"
msgstr ""
#: py/compile.c:2463 py/compile.c:2473 py/compile.c:2712 py/compile.c:2742
#: py/parse.c:1176
msgid "invalid syntax"
msgstr ""
#: py/compile.c:2465
msgid "expecting key:value for dict"
msgstr ""
#: py/compile.c:2475
msgid "expecting just a value for set"
msgstr ""
#: py/compile.c:2600
msgid "'yield' outside function"
msgstr ""
#: py/compile.c:2619
msgid "'await' outside function"
msgstr ""
#: py/compile.c:2774
msgid "name reused for argument"
msgstr ""
#: py/compile.c:2827
msgid "parameter annotation must be an identifier"
msgstr ""
#: py/compile.c:2969 py/compile.c:3137
msgid "return annotation must be an identifier"
msgstr ""
#: py/compile.c:3097
msgid "inline assembler must be a function"
msgstr ""
#: py/compile.c:3134
msgid "unknown type"
msgstr ""
#: py/compile.c:3154
msgid "expecting an assembler instruction"
msgstr ""
#: py/compile.c:3184
msgid "'label' requires 1 argument"
msgstr ""
#: py/compile.c:3190
msgid "label redefined"
msgstr ""
#: py/compile.c:3196
msgid "'align' requires 1 argument"
msgstr ""
#: py/compile.c:3205
msgid "'data' requires at least 2 arguments"
msgstr ""
#: py/compile.c:3212
msgid "'data' requires integer arguments"
msgstr ""
#: py/modbuiltins.c:162
msgid "chr() arg not in range(0x110000)"
msgstr ""
@ -331,6 +476,462 @@ msgstr ""
msgid "buffer too small"
msgstr ""
#: py/obj.c:89
msgid "Traceback (most recent call last):\n"
msgstr ""
#: py/obj.c:92
msgid " File \"%q\", line %d"
msgstr ""
#: py/obj.c:94
msgid " File \"%q\""
msgstr ""
#: py/obj.c:101
msgid ", in %q\n"
msgstr ""
#: py/objint_mpz.c:230 py/runtime.c:619 shared-bindings/math/__init__.c:346
msgid "division by zero"
msgstr ""
#: py/objint_mpz.c:267 py/runtime.c:396 py/runtime.c:411
msgid "negative shift count"
msgstr ""
#: py/objint_mpz.c:283 py/runtime.c:486
msgid "negative power with no float support"
msgstr ""
#: py/objint_mpz.c:336
msgid "pow() with 3 arguments requires integers"
msgstr ""
#: py/objint_mpz.c:347
msgid "pow() 3rd argument cannot be 0"
msgstr ""
#: py/objint_mpz.c:415
msgid "overflow converting long int to machine word"
msgstr ""
#: py/objlist.c:273
msgid "pop from empty list"
msgstr ""
#: py/objnamedtuple.c:92
msgid "can't set attribute"
msgstr ""
#: py/objnamedtuple.c:104
#, c-format
msgid "function takes %d positional arguments but %d were given"
msgstr ""
#: py/objnamedtuple.c:108
msgid "%q() takes %d positional arguments but %d were given"
msgstr ""
#: py/objnamedtuple.c:130
msgid "unexpected keyword argument '%q'"
msgstr ""
#: py/objnamedtuple.c:138
msgid "function got multiple values for argument '%q'"
msgstr ""
#: py/objobject.c:55
msgid "__new__ arg must be a user-type"
msgstr ""
#: py/objrange.c:110
msgid "zero step"
msgstr ""
#: py/objset.c:371
msgid "pop from an empty set"
msgstr ""
#: py/objslice.c:66
msgid "Length must be an int"
msgstr ""
#: py/objslice.c:71
msgid "Length must be non-negative"
msgstr ""
#: py/objslice.c:86 py/sequence.c:57
msgid "slice step cannot be zero"
msgstr ""
#: py/objslice.c:159
msgid "Cannot subclass slice"
msgstr ""
#: py/objstr.c:261
msgid "bytes value out of range"
msgstr ""
#: py/objstr.c:270
msgid "wrong number of arguments"
msgstr ""
#: py/objstr.c:427 py/objstrunicode.c:191 py/objtuple.c:187
#: shared-bindings/nvm/ByteArray.c:85
msgid "only slices with step=1 (aka None) are supported"
msgstr ""
#: py/objstr.c:467
msgid "join expects a list of str/bytes objects consistent with self object"
msgstr ""
#: py/objstr.c:542 py/objstr.c:647 py/objstr.c:1744
msgid "empty separator"
msgstr ""
#: py/objstr.c:641
msgid "rsplit(None,n)"
msgstr ""
#: py/objstr.c:713
msgid "substring not found"
msgstr ""
#: py/objstr.c:770
msgid "start/end indices"
msgstr ""
#: py/objstr.c:931
msgid "bad format string"
msgstr ""
#: py/objstr.c:953
msgid "single '}' encountered in format string"
msgstr ""
#: py/objstr.c:992
msgid "bad conversion specifier"
msgstr ""
#: py/objstr.c:996
msgid "end of format while looking for conversion specifier"
msgstr ""
#: py/objstr.c:998
#, c-format
msgid "unknown conversion specifier %c"
msgstr ""
#: py/objstr.c:1029
msgid "unmatched '{' in format"
msgstr ""
#: py/objstr.c:1036
msgid "expected ':' after format specifier"
msgstr ""
#: py/objstr.c:1050
msgid ""
"can't switch from automatic field numbering to manual field specification"
msgstr ""
#: py/objstr.c:1055 py/objstr.c:1083
msgid "tuple index out of range"
msgstr ""
#: py/objstr.c:1071
msgid "attributes not supported yet"
msgstr ""
#: py/objstr.c:1079
msgid ""
"can't switch from manual field specification to automatic field numbering"
msgstr ""
#: py/objstr.c:1171
msgid "invalid format specifier"
msgstr ""
#: py/objstr.c:1192
msgid "sign not allowed in string format specifier"
msgstr ""
#: py/objstr.c:1200
msgid "sign not allowed with integer format specifier 'c'"
msgstr ""
#: py/objstr.c:1259
#, c-format
msgid "unknown format code '%c' for object of type '%s'"
msgstr ""
#: py/objstr.c:1331
#, c-format
msgid "unknown format code '%c' for object of type 'float'"
msgstr ""
#: py/objstr.c:1343
msgid "'=' alignment not allowed in string format specifier"
msgstr ""
#: py/objstr.c:1367
#, c-format
msgid "unknown format code '%c' for object of type 'str'"
msgstr ""
#: py/objstr.c:1415
msgid "format requires a dict"
msgstr ""
#: py/objstr.c:1424
msgid "incomplete format key"
msgstr ""
#: py/objstr.c:1482
msgid "incomplete format"
msgstr ""
#: py/objstr.c:1490
msgid "not enough arguments for format string"
msgstr ""
#: py/objstr.c:1500
#, c-format
msgid "%%c requires int or char"
msgstr ""
#: py/objstr.c:1507
msgid "integer required"
msgstr ""
#: py/objstr.c:1570
#, c-format
msgid "unsupported format character '%c' (0x%x) at index %d"
msgstr ""
#: py/objstr.c:1577
msgid "not all arguments converted during string formatting"
msgstr ""
#: py/objstr.c:2102
msgid "can't convert to str implicitly"
msgstr ""
#: py/objstr.c:2106
msgid "can't convert '%q' object to %q implicitly"
msgstr ""
#: py/objstringio.c:43
msgid "I/O operation on closed file"
msgstr ""
#: py/objstrunicode.c:134
#, c-format
msgid "string indices must be integers, not %s"
msgstr ""
#: py/objstrunicode.c:145 py/objstrunicode.c:164
msgid "string index out of range"
msgstr ""
#: py/objtype.c:358
msgid "__init__() should return None"
msgstr ""
#: py/objtype.c:360
#, c-format
msgid "__init__() should return None, not '%s'"
msgstr ""
#: py/objtype.c:623 py/objtype.c:1275 py/runtime.c:1065
msgid "unreadable attribute"
msgstr ""
#: py/objtype.c:868 py/runtime.c:653
msgid "object not callable"
msgstr ""
#: py/objtype.c:870 py/runtime.c:655
#, c-format
msgid "'%s' object is not callable"
msgstr ""
#: py/objtype.c:978
msgid "type takes 1 or 3 arguments"
msgstr ""
#: py/objtype.c:989
msgid "cannot create instance"
msgstr ""
#: py/objtype.c:991
msgid "cannot create '%q' instances"
msgstr ""
#: py/objtype.c:1047
msgid "can't add special method to already-subclassed class"
msgstr ""
#: py/objtype.c:1091 py/objtype.c:1097
msgid "type is not an acceptable base type"
msgstr ""
#: py/objtype.c:1100
msgid "type '%q' is not an acceptable base type"
msgstr ""
#: py/objtype.c:1137
msgid "multiple inheritance not supported"
msgstr ""
#: py/objtype.c:1164
msgid "multiple bases have instance lay-out conflict"
msgstr ""
#: py/objtype.c:1205
msgid "first argument to super() must be type"
msgstr ""
#: py/objtype.c:1370
msgid "issubclass() arg 2 must be a class or a tuple of classes"
msgstr ""
#: py/objtype.c:1384
msgid "issubclass() arg 1 must be a class"
msgstr ""
#: py/parse.c:726
msgid "constant must be an integer"
msgstr ""
#: py/parse.c:868
msgid "Unable to init parser"
msgstr ""
#: py/parse.c:1170
msgid "unexpected indent"
msgstr ""
#: py/parse.c:1173
msgid "unindent does not match any outer indentation level"
msgstr ""
#: py/parsenum.c:60
msgid "int() arg 2 must be >= 2 and <= 36"
msgstr ""
#: py/persistentcode.c:223
msgid ""
"Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/"
"mpy-update for more info."
msgstr ""
#: py/persistentcode.c:326
msgid "can only save bytecode"
msgstr ""
#: py/runtime.c:206
msgid "name not defined"
msgstr ""
#: py/runtime.c:209
msgid "name '%q' is not defined"
msgstr ""
#: py/runtime.c:304 py/runtime.c:611
msgid "unsupported type for operator"
msgstr ""
#: py/runtime.c:307
msgid "unsupported type for %q: '%s'"
msgstr ""
#: py/runtime.c:614
msgid "unsupported types for %q: '%s', '%s'"
msgstr ""
#: py/runtime.c:881 py/runtime.c:888 py/runtime.c:945
msgid "wrong number of values to unpack"
msgstr ""
#: py/runtime.c:883 py/runtime.c:947
#, c-format
msgid "need more than %d values to unpack"
msgstr ""
#: py/runtime.c:890
#, c-format
msgid "too many values to unpack (expected %d)"
msgstr ""
#: py/runtime.c:984
msgid "argument has wrong type"
msgstr ""
#: py/runtime.c:986
msgid "argument should be a '%q' not a '%q'"
msgstr ""
#: py/runtime.c:1123 py/runtime.c:1197
msgid "no such attribute"
msgstr ""
#: py/runtime.c:1128
msgid "type object '%q' has no attribute '%q'"
msgstr ""
#: py/runtime.c:1132 py/runtime.c:1200
msgid "'%s' object has no attribute '%q'"
msgstr ""
#: py/runtime.c:1238
msgid "object not iterable"
msgstr ""
#: py/runtime.c:1241
#, c-format
msgid "'%s' object is not iterable"
msgstr ""
#: py/runtime.c:1260 py/runtime.c:1296
msgid "object not an iterator"
msgstr ""
#: py/runtime.c:1262 py/runtime.c:1298
#, c-format
msgid "'%s' object is not an iterator"
msgstr ""
#: py/runtime.c:1401
msgid "exceptions must derive from BaseException"
msgstr ""
#: py/runtime.c:1430
msgid "cannot import name %q"
msgstr ""
#: py/runtime.c:1535
msgid "memory allocation failed, heap is locked"
msgstr ""
#: py/runtime.c:1539
#, c-format
msgid "memory allocation failed, allocating %u bytes"
msgstr ""
#: py/runtime.c:1609
msgid "maximum recursion depth exceeded"
msgstr ""
#: py/sequence.c:264
msgid "object not in sequence"
msgstr ""
#: py/stream.c:96
msgid "stream operation not supported"
msgstr ""
#: shared-bindings/_stage/Layer.c:71
msgid "graphic must be 2048 bytes long"
msgstr ""
@ -474,16 +1075,16 @@ msgstr ""
msgid "math domain error"
msgstr ""
#: shared-bindings/math/__init__.c:346
msgid "division by zero"
msgstr ""
#: shared-bindings/microcontroller/Pin.c:89
#: shared-bindings/neopixel_write/__init__.c:67
#: shared-bindings/pulseio/PulseOut.c:75
msgid "Expected a %q"
msgstr ""
#: shared-bindings/microcontroller/Pin.c:100
msgid "%q in use"
msgstr ""
#: shared-bindings/microcontroller/__init__.c:126
msgid "Invalid run mode."
msgstr ""
@ -492,10 +1093,6 @@ msgstr ""
msgid "Stream missing readinto() or write() method."
msgstr ""
#: shared-bindings/nvm/ByteArray.c:85
msgid "only slices with step=1 (aka None) are supported"
msgstr ""
#: shared-bindings/nvm/ByteArray.c:99
msgid "Slice and value different lengths."
msgstr ""

View File

@ -29,6 +29,8 @@
#include "py/runtime.h"
#include "supervisor/shared/translate.h"
void mp_arg_check_num(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, bool takes_kw) {
// NOTE(tannewt): This prevents this function from being optimized away.
// Without it, functions can crash when reading invalid args.
@ -39,7 +41,7 @@ void mp_arg_check_num(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_ar
#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(translate("function does not take keyword arguments"));
#endif
}
@ -49,7 +51,7 @@ void mp_arg_check_num(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_ar
mp_arg_error_terse_mismatch();
#else
mp_raise_TypeError_varg(
"function takes %d positional arguments but %d were given",
translate("function takes %d positional arguments but %d were given"),
n_args_min, n_args);
#endif
}
@ -59,7 +61,7 @@ void mp_arg_check_num(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_ar
mp_arg_error_terse_mismatch();
#else
mp_raise_TypeError_varg(
"function missing %d required positional arguments",
translate("function missing %d required positional arguments"),
n_args_min - n_args);
#endif
} else if (n_args > n_args_max) {
@ -67,7 +69,7 @@ void mp_arg_check_num(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_ar
mp_arg_error_terse_mismatch();
#else
mp_raise_TypeError_varg(
"function expected at most %d arguments, got %d",
translate("function expected at most %d arguments, got %d"),
n_args_max, n_args);
#endif
}
@ -92,7 +94,7 @@ void mp_arg_parse_all(size_t n_pos, const mp_obj_t *pos, mp_map_t *kws, size_t n
mp_arg_error_terse_mismatch();
} else {
mp_raise_TypeError_varg(
"'%q' argument required", allowed[i].qst);
translate("'%q' argument required"), allowed[i].qst);
}
}
out_vals[i] = allowed[i].defval;
@ -117,7 +119,7 @@ void mp_arg_parse_all(size_t n_pos, const mp_obj_t *pos, mp_map_t *kws, size_t n
mp_arg_error_terse_mismatch();
} else {
// TODO better error message
mp_raise_TypeError("extra positional arguments given");
mp_raise_TypeError(translate("extra positional arguments given"));
}
}
if (kws_found < kws->used) {
@ -125,7 +127,7 @@ void mp_arg_parse_all(size_t n_pos, const mp_obj_t *pos, mp_map_t *kws, size_t n
mp_arg_error_terse_mismatch();
} else {
// TODO better error message
mp_raise_TypeError("extra keyword arguments given");
mp_raise_TypeError(translate("extra keyword arguments given"));
}
}
}
@ -137,11 +139,11 @@ void mp_arg_parse_all_kw_array(size_t n_pos, size_t n_kw, const mp_obj_t *args,
}
NORETURN void mp_arg_error_terse_mismatch(void) {
mp_raise_TypeError("argument num/types mismatch");
mp_raise_TypeError(translate("argument num/types mismatch"));
}
#if MICROPY_CPYTHON_COMPAT
NORETURN void mp_arg_error_unimpl_kw(void) {
mp_raise_NotImplementedError("keyword argument(s) not yet implemented - use normal args instead");
mp_raise_NotImplementedError(translate("keyword argument(s) not yet implemented - use normal args instead"));
}
#endif

22
py/bc.c
View File

@ -33,6 +33,8 @@
#include "py/bc0.h"
#include "py/bc.h"
#include "supervisor/shared/translate.h"
#if MICROPY_DEBUG_VERBOSE // print debugging info
#define DEBUG_PRINT (1)
#else // don't print debugging info
@ -80,10 +82,10 @@ STATIC NORETURN void fun_pos_args_mismatch(mp_obj_fun_bc_t *f, size_t expected,
#elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL
(void)f;
mp_raise_TypeError_varg(
"function takes %d positional arguments but %d were given", expected, given);
translate("function takes %d positional arguments but %d were given"), expected, given);
#elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
mp_raise_TypeError_varg(
"%q() takes %d positional arguments but %d were given",
translate("%q() takes %d positional arguments but %d were given"),
mp_obj_fun_get_name(MP_OBJ_FROM_PTR(f)), expected, given);
#endif
}
@ -192,16 +194,16 @@ void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw
mp_obj_t wanted_arg_name = kwargs[2 * i];
if(MP_UNLIKELY(!MP_OBJ_IS_QSTR(wanted_arg_name))) {
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
mp_raise_TypeError("unexpected keyword argument");
mp_raise_TypeError(translate("unexpected keyword argument"));
#else
mp_raise_TypeError("keywords must be strings");
mp_raise_TypeError(translate("keywords must be strings"));
#endif
}
for (size_t j = 0; j < n_pos_args + n_kwonly_args; j++) {
if (wanted_arg_name == arg_names[j]) {
if (code_state->state[n_state - 1 - j] != MP_OBJ_NULL) {
mp_raise_TypeError_varg(
"function got multiple values for argument '%q'", MP_OBJ_QSTR_VALUE(wanted_arg_name));
translate("function got multiple values for argument '%q'"), MP_OBJ_QSTR_VALUE(wanted_arg_name));
}
code_state->state[n_state - 1 - j] = kwargs[2 * i + 1];
goto continue2;
@ -210,10 +212,10 @@ void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw
// Didn't find name match with positional args
if ((scope_flags & MP_SCOPE_FLAG_VARKEYWORDS) == 0) {
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
mp_raise_TypeError("unexpected keyword argument");
mp_raise_TypeError(translate("unexpected keyword argument"));
#else
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
"unexpected keyword argument '%q'", MP_OBJ_QSTR_VALUE(wanted_arg_name)));
translate("unexpected keyword argument '%q'"), MP_OBJ_QSTR_VALUE(wanted_arg_name)));
#endif
}
mp_obj_dict_store(dict, kwargs[2 * i], kwargs[2 * i + 1]);
@ -239,7 +241,7 @@ continue2:;
while (d < &code_state->state[n_state]) {
if (*d++ == MP_OBJ_NULL) {
mp_raise_TypeError_varg(
"function missing required positional argument #%d", &code_state->state[n_state] - d);
translate("function missing required positional argument #%d"), &code_state->state[n_state] - d);
}
}
@ -255,7 +257,7 @@ continue2:;
code_state->state[n_state - 1 - n_pos_args - i] = elem->value;
} else {
mp_raise_TypeError_varg(
"function missing required keyword argument '%q'",
translate("function missing required keyword argument '%q'"),
MP_OBJ_QSTR_VALUE(arg_names[n_pos_args + i]));
}
}
@ -264,7 +266,7 @@ continue2:;
} else {
// no keyword arguments given
if (n_kwonly_args != 0) {
mp_raise_TypeError("function missing keyword-only argument");
mp_raise_TypeError(translate("function missing keyword-only argument"));
}
if ((scope_flags & MP_SCOPE_FLAG_VARKEYWORDS) != 0) {
*var_pos_kw_args = mp_obj_new_dict(0);

View File

@ -35,6 +35,8 @@
#include "py/objint.h"
#include "py/runtime.h"
#include "supervisor/shared/translate.h"
// Helpers to work with binary-encoded data
#ifndef alignof
@ -107,7 +109,7 @@ size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign) {
}
if (size == 0) {
mp_raise_ValueError("bad typecode");
mp_raise_ValueError(translate("bad typecode"));
}
if (palign != NULL) {

View File

@ -31,6 +31,8 @@
#include "py/runtime.h"
#include "py/builtin.h"
#include "supervisor/shared/translate.h"
#if MICROPY_PY_BUILTINS_COMPILE
typedef struct _mp_obj_code_t {
@ -94,7 +96,7 @@ STATIC mp_obj_t mp_builtin_compile(size_t n_args, const mp_obj_t *args) {
case MP_QSTR_exec: parse_input_kind = MP_PARSE_FILE_INPUT; break;
case MP_QSTR_eval: parse_input_kind = MP_PARSE_EVAL_INPUT; break;
default:
mp_raise_ValueError("bad compile mode");
mp_raise_ValueError(translate("bad compile mode"));
}
mp_obj_code_t *code = m_new_obj(mp_obj_code_t);

View File

@ -38,6 +38,8 @@
#include "py/builtin.h"
#include "py/frozenmod.h"
#include "supervisor/shared/translate.h"
#if MICROPY_DEBUG_VERBOSE // print debugging info
#define DEBUG_PRINT (1)
#define DEBUG_printf DEBUG_printf
@ -248,7 +250,7 @@ STATIC void do_load(mp_obj_t module_obj, vstr_t *file) {
#else
// If we get here then the file was not frozen and we can't compile scripts.
mp_raise_ImportError("script compilation not supported");
mp_raise_ImportError(translate("script compilation not supported"));
#endif
}
@ -333,7 +335,7 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
// We must have some component left over to import from
if (p == this_name) {
mp_raise_ValueError("cannot perform relative import");
mp_raise_ValueError(translate("cannot perform relative import"));
}
uint new_mod_l = (mod_len == 0 ? (size_t)(p - this_name) : (size_t)(p - this_name) + 1 + mod_len);
@ -417,10 +419,10 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
#endif
// couldn't find the file, so fail
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_ImportError("module not found");
mp_raise_ImportError(translate("module not found"));
} else {
mp_raise_msg_varg(&mp_type_ImportError,
"no module named '%q'", mod_name);
translate("no module named '%q'"), mod_name);
}
}
} else {
@ -507,7 +509,7 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
// Check that it's not a relative import
if (n_args >= 5 && MP_OBJ_SMALL_INT_VALUE(args[4]) != 0) {
mp_raise_NotImplementedError("relative import");
mp_raise_NotImplementedError(translate("relative import"));
}
// Check if module already exists, and return it if it does
@ -529,10 +531,10 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
// Couldn't find the module, so fail
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_msg(&mp_type_ImportError, "module not found");
mp_raise_msg(&mp_type_ImportError, translate("module not found"));
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ImportError,
"no module named '%q'", module_name_qstr));
translate("no module named '%q'"), module_name_qstr));
}
}

View File

@ -36,6 +36,8 @@
#include "py/runtime.h"
#include "py/asmbase.h"
#include "supervisor/shared/translate.h"
#if MICROPY_ENABLE_COMPILER
// TODO need to mangle __attr names
@ -392,7 +394,7 @@ STATIC void c_assign_atom_expr(compiler_t *comp, mp_parse_node_struct_t *pns, as
}
}
compile_syntax_error(comp, (mp_parse_node_t)pns, "can't assign to expression");
compile_syntax_error(comp, (mp_parse_node_t)pns, translate("can't assign to expression"));
}
// we need to allow for a caller passing in 1 initial node (node_head) followed by an array of nodes (nodes_tail)
@ -411,7 +413,7 @@ STATIC void c_assign_tuple(compiler_t *comp, mp_parse_node_t node_head, uint num
EMIT_ARG(unpack_ex, num_head + i, num_tail - i - 1);
have_star_index = num_head + i;
} else {
compile_syntax_error(comp, nodes_tail[i], "multiple *x in assignment");
compile_syntax_error(comp, nodes_tail[i], translate("multiple *x in assignment"));
return;
}
}
@ -537,7 +539,7 @@ STATIC void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t assign_
return;
cannot_assign:
compile_syntax_error(comp, pn, "can't assign to expression");
compile_syntax_error(comp, pn, translate("can't assign to expression"));
}
// stuff for lambda and comprehensions and generators:
@ -637,7 +639,7 @@ STATIC void compile_funcdef_lambdef_param(compiler_t *comp, mp_parse_node_t pn)
// check for non-default parameters given after default parameters (allowed by parser, but not syntactically valid)
if (!comp->have_star && comp->num_default_params != 0) {
compile_syntax_error(comp, pn, "non-default argument follows default argument");
compile_syntax_error(comp, pn, translate("non-default argument follows default argument"));
return;
}
@ -766,7 +768,7 @@ STATIC bool compile_built_in_decorator(compiler_t *comp, int name_len, mp_parse_
}
if (name_len != 2) {
compile_syntax_error(comp, name_nodes[0], "invalid micropython decorator");
compile_syntax_error(comp, name_nodes[0], translate("invalid micropython decorator"));
return true;
}
@ -784,7 +786,7 @@ STATIC bool compile_built_in_decorator(compiler_t *comp, int name_len, mp_parse_
*emit_options = MP_EMIT_OPT_ASM;
#endif
} else {
compile_syntax_error(comp, name_nodes[1], "invalid micropython decorator");
compile_syntax_error(comp, name_nodes[1], translate("invalid micropython decorator"));
}
return true;
@ -938,7 +940,7 @@ STATIC void c_del_stmt(compiler_t *comp, mp_parse_node_t pn) {
return;
cannot_delete:
compile_syntax_error(comp, (mp_parse_node_t)pn, "can't delete expression");
compile_syntax_error(comp, (mp_parse_node_t)pn, translate("can't delete expression"));
}
STATIC void compile_del_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
@ -950,10 +952,10 @@ STATIC void compile_break_cont_stmt(compiler_t *comp, mp_parse_node_struct_t *pn
const char *error_msg;
if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_break_stmt) {
label = comp->break_label;
error_msg = "'break' outside loop";
error_msg = translate("'break' outside loop");
} else {
label = comp->continue_label;
error_msg = "'continue' outside loop";
error_msg = translate("'continue' outside loop");
}
if (label == INVALID_LABEL) {
compile_syntax_error(comp, (mp_parse_node_t)pns, error_msg);
@ -964,7 +966,7 @@ STATIC void compile_break_cont_stmt(compiler_t *comp, mp_parse_node_struct_t *pn
STATIC void compile_return_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
if (comp->scope_cur->kind != SCOPE_FUNCTION) {
compile_syntax_error(comp, (mp_parse_node_t)pns, "'return' outside function");
compile_syntax_error(comp, (mp_parse_node_t)pns, translate("'return' outside function"));
return;
}
if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) {
@ -1164,7 +1166,7 @@ STATIC void compile_import_from(compiler_t *comp, mp_parse_node_struct_t *pns) {
STATIC void compile_declare_global(compiler_t *comp, mp_parse_node_t pn, qstr qst, bool added, id_info_t *id_info) {
if (!added && id_info->kind != ID_INFO_KIND_GLOBAL_EXPLICIT) {
compile_syntax_error(comp, pn, "identifier redefined as global");
compile_syntax_error(comp, pn, translate("identifier redefined as global"));
return;
}
id_info->kind = ID_INFO_KIND_GLOBAL_EXPLICIT;
@ -1180,10 +1182,10 @@ STATIC void compile_declare_nonlocal(compiler_t *comp, mp_parse_node_t pn, qstr
if (added) {
scope_find_local_and_close_over(comp->scope_cur, id_info, qst);
if (id_info->kind == ID_INFO_KIND_GLOBAL_IMPLICIT) {
compile_syntax_error(comp, pn, "no binding for nonlocal found");
compile_syntax_error(comp, pn, translate("no binding for nonlocal found"));
}
} else if (id_info->kind != ID_INFO_KIND_FREE) {
compile_syntax_error(comp, pn, "identifier redefined as nonlocal");
compile_syntax_error(comp, pn, translate("identifier redefined as nonlocal"));
}
}
@ -1192,7 +1194,7 @@ STATIC void compile_global_nonlocal_stmt(compiler_t *comp, mp_parse_node_struct_
bool is_global = MP_PARSE_NODE_STRUCT_KIND(pns) == PN_global_stmt;
if (!is_global && comp->scope_cur->kind == SCOPE_MODULE) {
compile_syntax_error(comp, (mp_parse_node_t)pns, "can't declare nonlocal in outer code");
compile_syntax_error(comp, (mp_parse_node_t)pns, translate("can't declare nonlocal in outer code"));
return;
}
@ -1537,7 +1539,7 @@ STATIC void compile_try_except(compiler_t *comp, mp_parse_node_t pn_body, int n_
if (MP_PARSE_NODE_IS_NULL(pns_except->nodes[0])) {
// this is a catch all exception handler
if (i + 1 != n_except) {
compile_syntax_error(comp, pn_excepts[i], "default 'except' must be last");
compile_syntax_error(comp, pn_excepts[i], translate("default 'except' must be last"));
compile_decrease_except_level(comp);
return;
}
@ -2090,7 +2092,7 @@ STATIC void compile_comparison(compiler_t *comp, mp_parse_node_struct_t *pns) {
}
STATIC void compile_star_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
compile_syntax_error(comp, (mp_parse_node_t)pns, "*x must be assignment target");
compile_syntax_error(comp, (mp_parse_node_t)pns, translate("*x must be assignment target"));
}
STATIC void compile_binary_op(compiler_t *comp, mp_parse_node_struct_t *pns) {
@ -2188,7 +2190,7 @@ STATIC void compile_atom_expr_normal(compiler_t *comp, mp_parse_node_struct_t *p
}
if (!found) {
compile_syntax_error(comp, (mp_parse_node_t)pns_trail[0],
"super() can't find self"); // really a TypeError
translate("super() can't find self")); // really a TypeError
return;
}
@ -2251,14 +2253,14 @@ STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_ar
mp_parse_node_struct_t *pns_arg = (mp_parse_node_struct_t*)args[i];
if (MP_PARSE_NODE_STRUCT_KIND(pns_arg) == PN_arglist_star) {
if (star_flags & MP_EMIT_STAR_FLAG_SINGLE) {
compile_syntax_error(comp, (mp_parse_node_t)pns_arg, "can't have multiple *x");
compile_syntax_error(comp, (mp_parse_node_t)pns_arg, translate("can't have multiple *x"));
return;
}
star_flags |= MP_EMIT_STAR_FLAG_SINGLE;
star_args_node = pns_arg;
} else if (MP_PARSE_NODE_STRUCT_KIND(pns_arg) == PN_arglist_dbl_star) {
if (star_flags & MP_EMIT_STAR_FLAG_DOUBLE) {
compile_syntax_error(comp, (mp_parse_node_t)pns_arg, "can't have multiple **x");
compile_syntax_error(comp, (mp_parse_node_t)pns_arg, translate("can't have multiple **x"));
return;
}
star_flags |= MP_EMIT_STAR_FLAG_DOUBLE;
@ -2266,7 +2268,7 @@ STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_ar
} else if (MP_PARSE_NODE_STRUCT_KIND(pns_arg) == PN_argument) {
if (!MP_PARSE_NODE_IS_STRUCT_KIND(pns_arg->nodes[1], PN_comp_for)) {
if (!MP_PARSE_NODE_IS_ID(pns_arg->nodes[0])) {
compile_syntax_error(comp, (mp_parse_node_t)pns_arg, "LHS of keyword arg must be an id");
compile_syntax_error(comp, (mp_parse_node_t)pns_arg, translate("LHS of keyword arg must be an id"));
return;
}
EMIT_ARG(load_const_str, MP_PARSE_NODE_LEAF_ARG(pns_arg->nodes[0]));
@ -2282,11 +2284,11 @@ STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_ar
} else {
normal_argument:
if (star_flags) {
compile_syntax_error(comp, args[i], "non-keyword arg after */**");
compile_syntax_error(comp, args[i], translate("non-keyword arg after */**"));
return;
}
if (n_keyword > 0) {
compile_syntax_error(comp, args[i], "non-keyword arg after keyword arg");
compile_syntax_error(comp, args[i], translate("non-keyword arg after keyword arg"));
return;
}
compile_node(comp, args[i]);
@ -2458,9 +2460,9 @@ STATIC void compile_atom_brace(compiler_t *comp, mp_parse_node_struct_t *pns) {
if (is_dict) {
if (!is_key_value) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
compile_syntax_error(comp, (mp_parse_node_t)pns, "invalid syntax");
compile_syntax_error(comp, (mp_parse_node_t)pns, translate("invalid syntax"));
} else {
compile_syntax_error(comp, (mp_parse_node_t)pns, "expecting key:value for dict");
compile_syntax_error(comp, (mp_parse_node_t)pns, translate("expecting key:value for dict"));
}
return;
}
@ -2468,9 +2470,9 @@ STATIC void compile_atom_brace(compiler_t *comp, mp_parse_node_struct_t *pns) {
} else {
if (is_key_value) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
compile_syntax_error(comp, (mp_parse_node_t)pns, "invalid syntax");
compile_syntax_error(comp, (mp_parse_node_t)pns, translate("invalid syntax"));
} else {
compile_syntax_error(comp, (mp_parse_node_t)pns, "expecting just a value for set");
compile_syntax_error(comp, (mp_parse_node_t)pns, translate("expecting just a value for set"));
}
return;
}
@ -2595,7 +2597,7 @@ STATIC void compile_classdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
STATIC void compile_yield_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
if (comp->scope_cur->kind != SCOPE_FUNCTION && comp->scope_cur->kind != SCOPE_LAMBDA) {
compile_syntax_error(comp, (mp_parse_node_t)pns, "'yield' outside function");
compile_syntax_error(comp, (mp_parse_node_t)pns, translate("'yield' outside function"));
return;
}
if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) {
@ -2614,7 +2616,7 @@ STATIC void compile_yield_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
#if MICROPY_PY_ASYNC_AWAIT
STATIC void compile_atom_expr_await(compiler_t *comp, mp_parse_node_struct_t *pns) {
if (comp->scope_cur->kind != SCOPE_FUNCTION && comp->scope_cur->kind != SCOPE_LAMBDA) {
compile_syntax_error(comp, (mp_parse_node_t)pns, "'await' outside function");
compile_syntax_error(comp, (mp_parse_node_t)pns, translate("'await' outside function"));
return;
}
compile_atom_expr_normal(comp, pns);
@ -2707,7 +2709,7 @@ STATIC void compile_node(compiler_t *comp, mp_parse_node_t pn) {
STATIC void compile_scope_func_lambda_param(compiler_t *comp, mp_parse_node_t pn, pn_kind_t pn_name, pn_kind_t pn_star, pn_kind_t pn_dbl_star) {
// check that **kw is last
if ((comp->scope_cur->scope_flags & MP_SCOPE_FLAG_VARKEYWORDS) != 0) {
compile_syntax_error(comp, pn, "invalid syntax");
compile_syntax_error(comp, pn, translate("invalid syntax"));
return;
}
@ -2737,7 +2739,7 @@ STATIC void compile_scope_func_lambda_param(compiler_t *comp, mp_parse_node_t pn
} else if (MP_PARSE_NODE_STRUCT_KIND(pns) == pn_star) {
if (comp->have_star) {
// more than one star
compile_syntax_error(comp, pn, "invalid syntax");
compile_syntax_error(comp, pn, translate("invalid syntax"));
return;
}
comp->have_star = true;
@ -2769,7 +2771,7 @@ STATIC void compile_scope_func_lambda_param(compiler_t *comp, mp_parse_node_t pn
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, translate("name reused for argument"));
return;
}
id_info->kind = ID_INFO_KIND_LOCAL;
@ -2822,7 +2824,7 @@ STATIC void compile_scope_func_annotations(compiler_t *comp, mp_parse_node_t pn)
qstr arg_type = MP_PARSE_NODE_LEAF_ARG(pn_annotation);
EMIT_ARG(set_native_type, MP_EMIT_NATIVE_TYPE_ARG, id_info->local_num, arg_type);
} else {
compile_syntax_error(comp, pn_annotation, "parameter annotation must be an identifier");
compile_syntax_error(comp, pn_annotation, translate("parameter annotation must be an identifier"));
}
}
}
@ -2964,7 +2966,7 @@ STATIC void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
qstr ret_type = MP_PARSE_NODE_LEAF_ARG(pn_annotation);
EMIT_ARG(set_native_type, MP_EMIT_NATIVE_TYPE_RETURN, 0, ret_type);
} else {
compile_syntax_error(comp, pn_annotation, "return annotation must be an identifier");
compile_syntax_error(comp, pn_annotation, translate("return annotation must be an identifier"));
}
}
}
@ -3092,7 +3094,7 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind
comp->next_label = 0;
if (scope->kind != SCOPE_FUNCTION) {
compile_syntax_error(comp, MP_PARSE_NODE_NULL, "inline assembler must be a function");
compile_syntax_error(comp, MP_PARSE_NODE_NULL, translate("inline assembler must be a function"));
return;
}
@ -3129,10 +3131,10 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind
case MP_QSTR_bool: type_sig = MP_NATIVE_TYPE_BOOL; break;
case MP_QSTR_int: type_sig = MP_NATIVE_TYPE_INT; break;
case MP_QSTR_uint: type_sig = MP_NATIVE_TYPE_UINT; break;
default: compile_syntax_error(comp, pn_annotation, "unknown type"); return;
default: compile_syntax_error(comp, pn_annotation, translate("unknown type")); return;
}
} else {
compile_syntax_error(comp, pn_annotation, "return annotation must be an identifier");
compile_syntax_error(comp, pn_annotation, translate("return annotation must be an identifier"));
}
}
@ -3149,7 +3151,7 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind
} else if (MP_PARSE_NODE_STRUCT_KIND(pns2) != PN_expr_stmt) {
// not an instruction; error
not_an_instruction:
compile_syntax_error(comp, nodes[i], "expecting an assembler instruction");
compile_syntax_error(comp, nodes[i], translate("expecting an assembler instruction"));
return;
}
@ -3179,19 +3181,19 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind
// emit instructions
if (op == MP_QSTR_label) {
if (!(n_args == 1 && MP_PARSE_NODE_IS_ID(pn_arg[0]))) {
compile_syntax_error(comp, nodes[i], "'label' requires 1 argument");
compile_syntax_error(comp, nodes[i], translate("'label' requires 1 argument"));
return;
}
uint lab = comp_next_label(comp);
if (pass > MP_PASS_SCOPE) {
if (!EMIT_INLINE_ASM_ARG(label, lab, MP_PARSE_NODE_LEAF_ARG(pn_arg[0]))) {
compile_syntax_error(comp, nodes[i], "label redefined");
compile_syntax_error(comp, nodes[i], translate("label redefined"));
return;
}
}
} else if (op == MP_QSTR_align) {
if (!(n_args == 1 && MP_PARSE_NODE_IS_SMALL_INT(pn_arg[0]))) {
compile_syntax_error(comp, nodes[i], "'align' requires 1 argument");
compile_syntax_error(comp, nodes[i], translate("'align' requires 1 argument"));
return;
}
if (pass > MP_PASS_SCOPE) {
@ -3200,14 +3202,14 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind
}
} else if (op == MP_QSTR_data) {
if (!(n_args >= 2 && MP_PARSE_NODE_IS_SMALL_INT(pn_arg[0]))) {
compile_syntax_error(comp, nodes[i], "'data' requires at least 2 arguments");
compile_syntax_error(comp, nodes[i], translate("'data' requires at least 2 arguments"));
return;
}
if (pass > MP_PASS_SCOPE) {
mp_int_t bytesize = MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[0]);
for (uint j = 1; j < n_args; j++) {
if (!MP_PARSE_NODE_IS_SMALL_INT(pn_arg[j])) {
compile_syntax_error(comp, nodes[i], "'data' requires integer arguments");
compile_syntax_error(comp, nodes[i], translate("'data' requires integer arguments"));
return;
}
mp_asm_base_data((mp_asm_base_t*)comp->emit_inline_asm,

View File

@ -49,6 +49,8 @@
#include "py/emit.h"
#include "py/bc.h"
#include "supervisor/shared/translate.h"
#if MICROPY_DEBUG_VERBOSE // print debugging info
#define DEBUG_PRINT (1)
#define DEBUG_printf DEBUG_printf
@ -737,7 +739,7 @@ STATIC void emit_get_stack_pointer_to_reg_for_pop(emit_t *emit, mp_uint_t reg_de
break;
default:
// not handled
mp_raise_NotImplementedError("conversion to object");
mp_raise_NotImplementedError(translate("conversion to object"));
}
}
@ -2121,7 +2123,7 @@ STATIC void emit_native_call_function(emit_t *emit, mp_uint_t n_positional, mp_u
break;
default:
// this can happen when casting a cast: int(int)
mp_raise_NotImplementedError("casting");
mp_raise_NotImplementedError(translate("casting"));
}
} else {
assert(vtype_fun == VTYPE_PYOBJ);
@ -2196,7 +2198,7 @@ STATIC void emit_native_yield(emit_t *emit, int kind) {
// not supported (for now)
(void)emit;
(void)kind;
mp_raise_NotImplementedError("native yield");
mp_raise_NotImplementedError(translate("native yield"));
}
STATIC void emit_native_start_except_handler(emit_t *emit) {

View File

@ -32,6 +32,8 @@
#include "py/lexer.h"
#include "py/runtime.h"
#include "supervisor/shared/translate.h"
#if MICROPY_ENABLE_COMPILER
#define TAB_SIZE (8)
@ -340,7 +342,7 @@ STATIC void parse_string_literal(mp_lexer_t *lex, bool is_raw) {
// 3MB of text; even gzip-compressed and with minimal structure, it'll take
// roughly half a meg of storage. This form of Unicode escape may be added
// later on, but it's definitely not a priority right now. -- CJA 20140607
mp_raise_NotImplementedError("unicode name escapes");
mp_raise_NotImplementedError(translate("unicode name escapes"));
break;
default:
if (c >= '0' && c <= '7') {

View File

@ -66,7 +66,7 @@ def translate(translation_file, i18ns):
with open(translation_file, "rb") as f:
table = gettext.GNUTranslations(f)
return [(x, table.gettext(x)) for x in i18ns]
return [(x, table.gettext(x.decode('string_escape'))) for x in i18ns]
def qstr_escape(qst):
def esc_char(m):
@ -181,6 +181,8 @@ def print_qstr_data(qcfgs, qstrs, i18ns):
total_text_size = 0
for original, translation in i18ns:
# Add in carriage returns to work in terminals
translation = translation.replace("\n", "\\r\\n")
print("TRANSLATION(\"{}\", \"{}\")".format(original, translation))
total_text_size += len(translation)

View File

@ -27,6 +27,8 @@
#include "py/builtin.h"
#include "py/runtime.h"
#include "supervisor/shared/translate.h"
#if MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_MATH
#include <math.h>
@ -36,7 +38,7 @@
#define MP_PI MICROPY_FLOAT_CONST(3.14159265358979323846)
STATIC NORETURN void math_error(void) {
mp_raise_ValueError("math domain error");
mp_raise_ValueError(translate("math domain error"));
}
STATIC mp_obj_t math_generic_1(mp_obj_t x_obj, mp_float_t (*f)(mp_float_t)) {
@ -191,7 +193,7 @@ STATIC mp_obj_t mp_math_log(size_t n_args, const mp_obj_t *args) {
#pragma GCC diagnostic ignored "-Wfloat-equal"
} else if (base == (mp_float_t)1.0) {
#pragma GCC diagnostic pop
mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero");
mp_raise_msg(&mp_type_ZeroDivisionError, translate("division by zero"));
}
return mp_obj_new_float(l / MICROPY_FLOAT_C_FUN(log)(base));
}

View File

@ -32,6 +32,8 @@
#include "py/gc.h"
#include "py/mphal.h"
#include "supervisor/shared/translate.h"
// Various builtins specific to MicroPython runtime,
// living in micropython module
@ -150,7 +152,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_micropython_kbd_intr_obj, mp_micropython_kbd
#if MICROPY_ENABLE_SCHEDULER
STATIC mp_obj_t mp_micropython_schedule(mp_obj_t function, mp_obj_t arg) {
if (!mp_sched_schedule(function, arg)) {
mp_raise_msg(&mp_type_RuntimeError, "schedule stack full");
mp_raise_msg(&mp_type_RuntimeError, translate("schedule stack full"));
}
return mp_const_none;
}

View File

@ -30,6 +30,8 @@
#include "py/runtime.h"
#include "py/stackctrl.h"
#include "supervisor/shared/translate.h"
#if MICROPY_PY_THREAD
#include "py/mpthread.h"
@ -235,7 +237,7 @@ STATIC mp_obj_t mod_thread_start_new_thread(size_t n_args, const mp_obj_t *args)
} else {
// positional and keyword arguments
if (mp_obj_get_type(args[2]) != &mp_type_dict) {
mp_raise_TypeError("expecting a dict for keyword args");
mp_raise_TypeError(translate("expecting a dict for keyword args"));
}
mp_map_t *map = &((mp_obj_dict_t*)MP_OBJ_TO_PTR(args[2]))->map;
th_args = m_new_obj_var(thread_entry_args_t, mp_obj_t, pos_args_len + 2 * map->used);

View File

@ -30,6 +30,8 @@
#include "py/obj.h"
#include "py/mperrno.h"
#include "supervisor/shared/translate.h"
// This list can be defined per port in mpconfigport.h to tailor it to a
// specific port's needs. If it's not defined then we provide a default.
#ifndef MICROPY_PY_UERRNO_LIST
@ -99,18 +101,18 @@ const mp_obj_module_t mp_module_uerrno = {
.globals = (mp_obj_dict_t*)&mp_module_uerrno_globals,
};
qstr mp_errno_to_str(mp_obj_t errno_val) {
const char* mp_errno_to_str(mp_obj_t errno_val) {
// For commonly encountered errors, return human readable strings
if (MP_OBJ_IS_SMALL_INT(errno_val)) {
switch (MP_OBJ_SMALL_INT_VALUE(errno_val)) {
case EPERM: return MP_QSTR_Permission_space_denied;
case ENOENT: return MP_QSTR_No_space_such_space_file_slash_directory;
case EIO: return MP_QSTR_Input_slash_output_space_error;
case EACCES: return MP_QSTR_Permission_space_denied;
case EEXIST: return MP_QSTR_File_space_exists;
case ENODEV: return MP_QSTR_Unsupported_space_operation;
case EINVAL: return MP_QSTR_Invalid_space_argument;
case EROFS: return MP_QSTR_Read_hyphen_only_space_filesystem;
case EPERM: return translate("Permission denied");
case ENOENT: return translate("No such file/directory");
case EIO: return translate("Input/output error");
case EACCES: return translate("Permission denied");
case EEXIST: return translate("File exists");
case ENODEV: return translate("Unsupported operation");
case EINVAL: return translate("Invalid argument");
case EROFS: return translate("Read-only filesystem");
}
}
@ -119,30 +121,30 @@ qstr mp_errno_to_str(mp_obj_t errno_val) {
// We have the errorcode dict so can do a lookup using the hash map
mp_map_elem_t *elem = mp_map_lookup((mp_map_t*)&errorcode_dict.map, errno_val, MP_MAP_LOOKUP);
if (elem == NULL) {
return MP_QSTR_NULL;
return "";
} else {
return MP_OBJ_QSTR_VALUE(elem->value);
return qstr_str(MP_OBJ_QSTR_VALUE(elem->value));
}
#else
// We don't have the errorcode dict so do a simple search in the modules dict
for (size_t i = 0; i < MP_ARRAY_SIZE(mp_module_uerrno_globals_table); ++i) {
if (errno_val == mp_module_uerrno_globals_table[i].value) {
return MP_OBJ_QSTR_VALUE(mp_module_uerrno_globals_table[i].key);
return qstr_str(MP_OBJ_QSTR_VALUE(mp_module_uerrno_globals_table[i].key));
}
}
return MP_QSTR_NULL;
return "";
#endif
}
#else //MICROPY_PY_UERRNO
qstr mp_errno_to_str(mp_obj_t errno_val) {
const char* mp_errno_to_str(mp_obj_t errno_val) {
int v = MP_OBJ_SMALL_INT_VALUE(errno_val);
#define X(e) if (v == e) return (MP_QSTR_ ## e);
#define X(e) if (v == e) return qstr_str(MP_QSTR_ ## e);
MICROPY_PY_UERRNO_LIST
#undef X
return MP_QSTR_;
return "";
}
#endif //MICROPY_PY_UERRNO

View File

@ -140,6 +140,6 @@
#endif
qstr mp_errno_to_str(mp_obj_t errno_val);
const char* mp_errno_to_str(mp_obj_t errno_val);
#endif // MICROPY_INCLUDED_PY_MPERRNO_H

View File

@ -37,6 +37,8 @@
#include "py/stackctrl.h"
#include "py/stream.h" // for mp_obj_print
#include "supervisor/shared/translate.h"
mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in) {
if (MP_OBJ_IS_SMALL_INT(o_in)) {
return (mp_obj_type_t*)&mp_type_int;
@ -84,19 +86,19 @@ void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc) {
mp_obj_exception_get_traceback(exc, &n, &values);
if (n > 0) {
assert(n % 3 == 0);
mp_print_str(print, "Traceback (most recent call last):\n");
mp_print_str(print, translate("Traceback (most recent call last):\n"));
for (int i = n - 3; i >= 0; i -= 3) {
#if MICROPY_ENABLE_SOURCE_LINE
mp_printf(print, " File \"%q\", line %d", values[i], (int)values[i + 1]);
mp_printf(print, translate(" File \"%q\", line %d"), values[i], (int)values[i + 1]);
#else
mp_printf(print, " File \"%q\"", values[i]);
mp_printf(print, translate(" File \"%q\""), values[i]);
#endif
// the block name can be NULL if it's unknown
qstr block = values[i + 2];
if (block == MP_QSTR_NULL) {
mp_print_str(print, "\n");
} else {
mp_printf(print, ", in %q\n", block);
mp_printf(print, translate(", in %q\n"), block);
}
}
}
@ -236,10 +238,10 @@ mp_int_t mp_obj_get_int(mp_const_obj_t arg) {
return mp_obj_int_get_checked(arg);
} else {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError("can't convert to int");
mp_raise_TypeError(translate("can't convert to int"));
} else {
mp_raise_TypeError_varg(
"can't convert %s to int", mp_obj_get_type_str(arg));
translate("can't convert %s to int"), mp_obj_get_type_str(arg));
}
}
}
@ -299,10 +301,10 @@ mp_float_t mp_obj_get_float(mp_obj_t arg) {
if (!mp_obj_get_float_maybe(arg, &val)) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError("can't convert to float");
mp_raise_TypeError(translate("can't convert to float"));
} else {
mp_raise_TypeError_varg(
"can't convert %s to float", mp_obj_get_type_str(arg));
translate("can't convert %s to float"), mp_obj_get_type_str(arg));
}
}
@ -332,10 +334,10 @@ void mp_obj_get_complex(mp_obj_t arg, mp_float_t *real, mp_float_t *imag) {
mp_obj_complex_get(arg, real, imag);
} else {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError("can't convert to complex");
mp_raise_TypeError(translate("can't convert to complex"));
} else {
mp_raise_TypeError_varg(
"can't convert %s to complex", mp_obj_get_type_str(arg));
translate("can't convert %s to complex"), mp_obj_get_type_str(arg));
}
}
}
@ -350,10 +352,10 @@ void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items) {
mp_obj_list_get(o, len, items);
} else {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError("expected tuple/list");
mp_raise_TypeError(translate("expected tuple/list"));
} else {
mp_raise_TypeError_varg(
"object '%s' is not a tuple or list", mp_obj_get_type_str(o));
translate("object '%s' is not a tuple or list"), mp_obj_get_type_str(o));
}
}
}
@ -364,9 +366,9 @@ void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items) {
mp_obj_get_array(o, &seq_len, items);
if (seq_len != len) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_ValueError("tuple/list has wrong length");
mp_raise_ValueError(translate("tuple/list has wrong length"));
} else {
mp_raise_ValueError_varg("requested length %d but object has length %d",
mp_raise_ValueError_varg(translate("requested length %d but object has length %d"),
(int)len, (int)seq_len);
}
}
@ -379,10 +381,10 @@ size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, bool
i = MP_OBJ_SMALL_INT_VALUE(index);
} else if (!mp_obj_get_int_maybe(index, &i)) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError("indices must be integers");
mp_raise_TypeError(translate("indices must be integers"));
} else {
mp_raise_TypeError_varg(
"%q indices must be integers, not %s",
translate("%q indices must be integers, not %s"),
type->name, mp_obj_get_type_str(index));
}
}
@ -399,10 +401,10 @@ size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, bool
} else {
if (i < 0 || (mp_uint_t)i >= len) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_IndexError("index out of range");
mp_raise_IndexError(translate("index out of range"));
} else {
mp_raise_msg_varg(&mp_type_IndexError,
"%q index out of range", type->name);
translate("%q index out of range"), type->name);
}
}
}
@ -434,10 +436,10 @@ mp_obj_t mp_obj_len(mp_obj_t o_in) {
mp_obj_t len = mp_obj_len_maybe(o_in);
if (len == MP_OBJ_NULL) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError("object has no len");
mp_raise_TypeError(translate("object has no len"));
} else {
mp_raise_TypeError_varg(
"object of type '%s' has no len()", mp_obj_get_type_str(o_in));
translate("object of type '%s' has no len()"), mp_obj_get_type_str(o_in));
}
} else {
return len;
@ -475,24 +477,24 @@ mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) {
}
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(translate("object does not support item deletion"));
} else {
mp_raise_TypeError_varg(
"'%s' object does not support item deletion", mp_obj_get_type_str(base));
translate("'%s' object does not 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(translate("object is not subscriptable"));
} else {
mp_raise_TypeError_varg(
"'%s' object is not subscriptable", mp_obj_get_type_str(base));
translate("'%s' object is not 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(translate("object does not support item assignment"));
} else {
mp_raise_TypeError_varg(
"'%s' object does not support item assignment", mp_obj_get_type_str(base));
translate("'%s' object does not support item assignment"), mp_obj_get_type_str(base));
}
}
}
@ -523,7 +525,7 @@ bool mp_get_buffer(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
void mp_get_buffer_raise(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
if (!mp_get_buffer(obj, bufinfo, flags)) {
mp_raise_TypeError("object with buffer protocol required");
mp_raise_TypeError(translate("object with buffer protocol required"));
}
}

View File

@ -34,6 +34,8 @@
#include "py/objstr.h"
#include "py/objarray.h"
#include "supervisor/shared/translate.h"
#if MICROPY_PY_ARRAY || MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_BUILTINS_MEMORYVIEW
// About memoryview object: We want to reuse as much code as possible from
@ -408,7 +410,7 @@ STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value
} else if (MP_OBJ_IS_TYPE(index_in, &mp_type_slice)) {
mp_bound_slice_t slice;
if (!mp_seq_get_fast_slice_indexes(o->len, index_in, &slice)) {
mp_raise_NotImplementedError("only slices with step=1 (aka None) are supported");
mp_raise_NotImplementedError(translate("only slices with step=1 (aka None) are supported"));
}
if (value != MP_OBJ_SENTINEL) {
#if MICROPY_PY_ARRAY_SLICE_ASSIGN
@ -421,7 +423,7 @@ STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value
mp_obj_array_t *src_slice = MP_OBJ_TO_PTR(value);
if (item_sz != mp_binary_get_size('@', src_slice->typecode & TYPECODE_MASK, NULL)) {
compat_error:
mp_raise_ValueError("lhs and rhs should be compatible");
mp_raise_ValueError(translate("lhs and rhs should be compatible"));
}
src_len = src_slice->len;
src_items = src_slice->items;
@ -439,7 +441,7 @@ STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value
src_len = bufinfo.len;
src_items = bufinfo.buf;
} else {
mp_raise_NotImplementedError("array/bytes required on right side");
mp_raise_NotImplementedError(translate("array/bytes required on right side"));
}
// TODO: check src/dst compat

View File

@ -31,6 +31,8 @@
#include "py/parsenum.h"
#include "py/runtime.h"
#include "supervisor/shared/translate.h"
#if MICROPY_PY_BUILTINS_COMPLEX
#include <math.h>
@ -198,13 +200,13 @@ mp_obj_t mp_obj_complex_binary_op(mp_binary_op_t op, mp_float_t lhs_real, mp_flo
}
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(translate("can't do truncated division of 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, translate("complex division by zero"));
}
lhs_real /= rhs_real;
lhs_imag /= rhs_real;
@ -232,7 +234,7 @@ mp_obj_t mp_obj_complex_binary_op(mp_binary_op_t op, mp_float_t lhs_real, mp_flo
if (rhs_imag == 0 && rhs_real >= 0) {
lhs_real = (rhs_real == 0);
} else {
mp_raise_msg(&mp_type_ZeroDivisionError, "0.0 to a complex power");
mp_raise_msg(&mp_type_ZeroDivisionError, translate("0.0 to a complex power"));
}
} else {
mp_float_t ln1 = MICROPY_FLOAT_C_FUN(log)(abs1);

View File

@ -28,6 +28,8 @@
#include <string.h>
#include "py/mpconfig.h"
#include "supervisor/shared/translate.h"
#if MICROPY_PY_COLLECTIONS_DEQUE
#include "py/runtime.h"
@ -102,7 +104,7 @@ STATIC mp_obj_t mp_obj_deque_append(mp_obj_t self_in, mp_obj_t arg) {
}
if (self->flags & FLAG_CHECK_OVERFLOW && new_i_put == self->i_get) {
mp_raise_msg(&mp_type_IndexError, "full");
mp_raise_msg(&mp_type_IndexError, translate("full"));
}
self->items[self->i_put] = arg;
@ -122,7 +124,7 @@ STATIC mp_obj_t deque_popleft(mp_obj_t self_in) {
mp_obj_deque_t *self = MP_OBJ_TO_PTR(self_in);
if (self->i_get == self->i_put) {
mp_raise_msg(&mp_type_IndexError, "empty");
mp_raise_msg(&mp_type_IndexError, translate("empty"));
}
mp_obj_t ret = self->items[self->i_get];

View File

@ -31,6 +31,8 @@
#include "py/builtin.h"
#include "py/objtype.h"
#include "supervisor/shared/translate.h"
#define MP_OBJ_IS_DICT_TYPE(o) (MP_OBJ_IS_OBJ(o) && ((mp_obj_base_t*)MP_OBJ_TO_PTR(o))->type->make_new == dict_make_new)
STATIC mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs);
@ -309,7 +311,7 @@ STATIC mp_obj_t dict_popitem(mp_obj_t self_in) {
size_t cur = 0;
mp_map_elem_t *next = dict_iter_next(self, &cur);
if (next == NULL) {
mp_raise_msg(&mp_type_KeyError, "popitem(): dictionary is empty");
mp_raise_msg(&mp_type_KeyError, translate("popitem(): dictionary is empty"));
}
self->map.used--;
mp_obj_t items[] = {next->key, next->value};
@ -352,7 +354,7 @@ STATIC mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwarg
if (key == MP_OBJ_STOP_ITERATION
|| value == MP_OBJ_STOP_ITERATION
|| stop != MP_OBJ_STOP_ITERATION) {
mp_raise_ValueError("dict update sequence has wrong length");
mp_raise_ValueError(translate("dict update sequence has wrong length"));
} else {
mp_map_lookup(&self->map, key, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value;
}

View File

@ -37,6 +37,8 @@
#include "py/gc.h"
#include "py/mperrno.h"
#include "supervisor/shared/translate.h"
// Number of items per traceback entry (file, line, block)
#define TRACEBACK_ENTRY_LEN (3)
@ -112,9 +114,9 @@ void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kin
} else if (o->args->len == 1) {
// try to provide a nice OSError error message
if (o->base.type == &mp_type_OSError && MP_OBJ_IS_SMALL_INT(o->args->items[0])) {
qstr qst = mp_errno_to_str(o->args->items[0]);
if (qst != MP_QSTR_NULL) {
mp_printf(print, "[Errno " INT_FMT "] %q", MP_OBJ_SMALL_INT_VALUE(o->args->items[0]), qst);
const char* msg = mp_errno_to_str(o->args->items[0]);
if (msg[0] != '\0') {
mp_printf(print, "[Errno " INT_FMT "] %s", MP_OBJ_SMALL_INT_VALUE(o->args->items[0]), msg);
return;
}
}

View File

@ -32,6 +32,8 @@
#include "py/parsenum.h"
#include "py/runtime.h"
#include "supervisor/shared/translate.h"
#if MICROPY_PY_BUILTINS_FLOAT
#include <math.h>
@ -265,7 +267,7 @@ mp_obj_t mp_obj_float_binary_op(mp_binary_op_t op, mp_float_t lhs_val, mp_obj_t
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, translate("division by zero"));
}
// Python specs require that x == (x//y)*y + (x%y) so we must
// call divmod to compute the correct floor division, which
@ -303,7 +305,7 @@ mp_obj_t mp_obj_float_binary_op(mp_binary_op_t op, mp_float_t lhs_val, mp_obj_t
#if MICROPY_PY_BUILTINS_COMPLEX
return mp_obj_complex_binary_op(MP_BINARY_OP_POWER, lhs_val, 0, rhs_in);
#else
mp_raise_ValueError("complex values not supported");
mp_raise_ValueError(translate("complex values not supported"));
#endif
}
lhs_val = MICROPY_FLOAT_C_FUN(pow)(lhs_val, rhs_val);

View File

@ -34,6 +34,8 @@
#include "py/objfun.h"
#include "py/stackctrl.h"
#include "supervisor/shared/translate.h"
/******************************************************************************/
/* generator wrapper */
@ -103,7 +105,7 @@ mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_
}
if (self->code_state.sp == self->code_state.state - 1) {
if (send_value != mp_const_none) {
mp_raise_TypeError("can't send non-None value to a just-started generator");
mp_raise_TypeError(translate("can't send non-None value to a just-started generator"));
}
} else {
#if MICROPY_PY_GENERATOR_PEND_THROW
@ -121,7 +123,7 @@ mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_
// We set self->globals=NULL while executing, for a sentinel to ensure the generator
// cannot be reentered during execution
if (self->globals == NULL) {
mp_raise_ValueError("generator already executing");
mp_raise_ValueError(translate("generator already executing"));
}
// Set up the correct globals context for the generator and execute it
@ -224,7 +226,7 @@ STATIC mp_obj_t gen_instance_close(mp_obj_t self_in) {
mp_obj_t ret;
switch (mp_obj_gen_resume(self_in, mp_const_none, MP_OBJ_FROM_PTR(&mp_const_GeneratorExit_obj), &ret)) {
case MP_VM_RETURN_YIELD:
mp_raise_RuntimeError("generator ignored GeneratorExit");
mp_raise_RuntimeError(translate("generator ignored GeneratorExit"));
// Swallow StopIteration & GeneratorExit (== successful close), and re-raise any other
case MP_VM_RETURN_EXCEPTION:
@ -246,7 +248,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(gen_instance_close_obj, gen_instance_close);
STATIC mp_obj_t gen_instance_pend_throw(mp_obj_t self_in, mp_obj_t exc_in) {
mp_obj_gen_instance_t *self = MP_OBJ_TO_PTR(self_in);
if (self->code_state.sp == self->code_state.state - 1) {
mp_raise_TypeError("can't pend throw to just-started generator");
mp_raise_TypeError(translate("can't pend throw to just-started generator"));
}
mp_obj_t prev = *self->code_state.sp;
*self->code_state.sp = exc_in;

View File

@ -35,6 +35,8 @@
#include "py/runtime.h"
#include "py/binary.h"
#include "supervisor/shared/translate.h"
#if MICROPY_PY_BUILTINS_FLOAT
#include <math.h>
#endif
@ -139,9 +141,9 @@ STATIC mp_fp_as_int_class_t mp_classify_fp_as_int(mp_float_t val) {
mp_obj_t mp_obj_new_int_from_float(mp_float_t val) {
int cl = fpclassify(val);
if (cl == FP_INFINITE) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OverflowError, "can't convert inf to int"));
nlr_raise(mp_obj_new_exception_msg(&mp_type_OverflowError, translate("can't convert inf to int")));
} else if (cl == FP_NAN) {
mp_raise_ValueError("can't convert NaN to int");
mp_raise_ValueError(translate("can't convert NaN to int"));
} else {
mp_fp_as_int_class_t icl = mp_classify_fp_as_int(val);
if (icl == MP_FP_CLASS_FIT_SMALLINT) {
@ -158,7 +160,7 @@ mp_obj_t mp_obj_new_int_from_float(mp_float_t val) {
return mp_obj_new_int_from_ll((long long)val);
#endif
} else {
mp_raise_ValueError("float too big");
mp_raise_ValueError(translate("float too big"));
}
#endif
}
@ -323,19 +325,19 @@ mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_i
// This is called only with strings whose value doesn't fit in SMALL_INT
mp_obj_t mp_obj_new_int_from_str_len(const char **str, size_t len, bool neg, unsigned int base) {
mp_raise_msg(&mp_type_OverflowError, "long int not supported in this build");
mp_raise_msg(&mp_type_OverflowError, translate("long int not supported in this build"));
return mp_const_none;
}
// This is called when an integer larger than a SMALL_INT is needed (although val might still fit in a SMALL_INT)
mp_obj_t mp_obj_new_int_from_ll(long long val) {
mp_raise_msg(&mp_type_OverflowError, "small int overflow");
mp_raise_msg(&mp_type_OverflowError, translate("small int overflow"));
return mp_const_none;
}
// This is called when an integer larger than a SMALL_INT is needed (although val might still fit in a SMALL_INT)
mp_obj_t mp_obj_new_int_from_ull(unsigned long long val) {
mp_raise_msg(&mp_type_OverflowError, "small int overflow");
mp_raise_msg(&mp_type_OverflowError, translate("small int overflow"));
return mp_const_none;
}
@ -345,7 +347,7 @@ mp_obj_t mp_obj_new_int_from_uint(mp_uint_t value) {
if ((value & ~MP_SMALL_INT_POSITIVE_MASK) == 0) {
return MP_OBJ_NEW_SMALL_INT(value);
}
mp_raise_msg(&mp_type_OverflowError, "small int overflow");
mp_raise_msg(&mp_type_OverflowError, translate("small int overflow"));
return mp_const_none;
}
@ -353,7 +355,7 @@ mp_obj_t mp_obj_new_int(mp_int_t value) {
if (MP_SMALL_INT_FITS(value)) {
return MP_OBJ_NEW_SMALL_INT(value);
}
mp_raise_msg(&mp_type_OverflowError, "small int overflow");
mp_raise_msg(&mp_type_OverflowError, translate("small int overflow"));
return mp_const_none;
}

View File

@ -32,6 +32,8 @@
#include "py/objint.h"
#include "py/runtime.h"
#include "supervisor/shared/translate.h"
#if MICROPY_PY_BUILTINS_FLOAT
#include <math.h>
#endif
@ -184,7 +186,7 @@ mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_i
#if MICROPY_PY_BUILTINS_FLOAT
return mp_obj_float_binary_op(op, lhs_val, rhs_in);
#else
mp_raise_ValueError("negative power with no float support");
mp_raise_ValueError(translate("negative power with no float support"));
#endif
}
long long ans = 1;
@ -217,7 +219,7 @@ mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_i
}
zero_division:
mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero");
mp_raise_msg(&mp_type_ZeroDivisionError, translate("division by zero"));
}
mp_obj_t mp_obj_new_int(mp_int_t value) {
@ -246,7 +248,7 @@ mp_obj_t mp_obj_new_int_from_ll(long long val) {
mp_obj_t mp_obj_new_int_from_ull(unsigned long long val) {
// TODO raise an exception if the unsigned long long won't fit
if (val >> (sizeof(unsigned long long) * 8 - 1) != 0) {
mp_raise_msg(&mp_type_OverflowError, "ulonglong too large");
mp_raise_msg(&mp_type_OverflowError, translate("ulonglong too large"));
}
mp_obj_int_t *o = m_new_obj(mp_obj_int_t);
o->base.type = &mp_type_int;

View File

@ -33,6 +33,8 @@
#include "py/objint.h"
#include "py/runtime.h"
#include "supervisor/shared/translate.h"
#if MICROPY_PY_BUILTINS_FLOAT
#include <math.h>
#endif
@ -225,7 +227,7 @@ mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_i
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, translate("division by zero"));
}
mpz_t rem; mpz_init_zero(&rem);
mpz_divmod_inpl(&res->mpz, &rem, zlhs, zrhs);
@ -262,7 +264,7 @@ mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_i
case MP_BINARY_OP_INPLACE_RSHIFT: {
mp_int_t irhs = mp_obj_int_get_checked(rhs_in);
if (irhs < 0) {
mp_raise_ValueError("negative shift count");
mp_raise_ValueError(translate("negative shift count"));
}
if (op == MP_BINARY_OP_LSHIFT || op == MP_BINARY_OP_INPLACE_LSHIFT) {
mpz_shl_inpl(&res->mpz, zlhs, irhs);
@ -278,7 +280,7 @@ mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_i
#if MICROPY_PY_BUILTINS_FLOAT
return mp_obj_float_binary_op(op, mpz_as_float(zlhs), rhs_in);
#else
mp_raise_ValueError("negative power with no float support");
mp_raise_ValueError(translate("negative power with no float support"));
#endif
}
mpz_pow_inpl(&res->mpz, zlhs, zrhs);
@ -331,7 +333,7 @@ STATIC mpz_t *mp_mpz_for_int(mp_obj_t arg, mpz_t *temp) {
mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus) {
if (!MP_OBJ_IS_INT(base) || !MP_OBJ_IS_INT(exponent) || !MP_OBJ_IS_INT(modulus)) {
mp_raise_TypeError("pow() with 3 arguments requires integers");
mp_raise_TypeError(translate("pow() with 3 arguments requires integers"));
} else {
mp_obj_t result = mp_obj_new_int_from_ull(0); // Use the _from_ull version as this forces an mpz int
mp_obj_int_t *res_p = (mp_obj_int_t *) MP_OBJ_TO_PTR(result);
@ -342,7 +344,7 @@ mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus) {
mpz_t *mod = mp_mpz_for_int(modulus, &m_temp);
if (mpz_is_zero(mod)) {
mp_raise_msg(&mp_type_ValueError, "pow() 3rd argument cannot be 0");
mp_raise_msg(&mp_type_ValueError, translate("pow() 3rd argument cannot be 0"));
}
mpz_pow3_inpl(&(res_p->mpz), lhs, rhs, mod);
@ -410,7 +412,7 @@ mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in) {
return value;
} else {
// overflow
mp_raise_msg(&mp_type_OverflowError, "overflow converting long int to machine word");
mp_raise_msg(&mp_type_OverflowError, translate("overflow converting long int to machine word"));
}
}
}

View File

@ -31,6 +31,8 @@
#include "py/runtime.h"
#include "py/stackctrl.h"
#include "supervisor/shared/translate.h"
STATIC mp_obj_t mp_obj_new_list_iterator(mp_obj_t list, size_t cur, mp_obj_iter_buf_t *iter_buf);
STATIC mp_obj_list_t *list_new(size_t n);
STATIC mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in);
@ -268,7 +270,7 @@ STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args) {
mp_check_self(MP_OBJ_IS_TYPE(args[0], &mp_type_list));
mp_obj_list_t *self = MP_OBJ_TO_PTR(args[0]);
if (self->len == 0) {
mp_raise_IndexError("pop from empty list");
mp_raise_IndexError(translate("pop from empty list"));
}
size_t index = mp_get_index(self->base.type, self->len, n_args == 1 ? MP_OBJ_NEW_SMALL_INT(-1) : args[1], false);
mp_obj_t ret = self->items[index];

View File

@ -32,6 +32,8 @@
#include "py/objstr.h"
#include "py/objnamedtuple.h"
#include "supervisor/shared/translate.h"
#if MICROPY_PY_COLLECTIONS
size_t mp_obj_namedtuple_find_field(const mp_obj_namedtuple_type_t *type, qstr name) {
@ -87,7 +89,7 @@ void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
} else {
// delete/store attribute
// provide more detailed error message than we'd get by just returning
mp_raise_AttributeError("can't set attribute");
mp_raise_AttributeError(translate("can't set attribute"));
}
}
@ -99,11 +101,11 @@ mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t
mp_arg_error_terse_mismatch();
} else if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL) {
mp_raise_TypeError_varg(
"function takes %d positional arguments but %d were given",
translate("function takes %d positional arguments but %d were given"),
num_fields, n_args + n_kw);
} else if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED) {
mp_raise_TypeError_varg(
"%q() takes %d positional arguments but %d were given",
translate("%q() takes %d positional arguments but %d were given"),
type->base.name, num_fields, n_args + n_kw);
}
}
@ -125,7 +127,7 @@ mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t
mp_arg_error_terse_mismatch();
} else {
mp_raise_TypeError_varg(
"unexpected keyword argument '%q'", kw);
translate("unexpected keyword argument '%q'"), kw);
}
}
if (tuple->items[id] != MP_OBJ_NULL) {
@ -133,7 +135,7 @@ mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t
mp_arg_error_terse_mismatch();
} else {
mp_raise_TypeError_varg(
"function got multiple values for argument '%q'", kw);
translate("function got multiple values for argument '%q'"), kw);
}
}
tuple->items[id] = args[i + 1];

View File

@ -29,6 +29,8 @@
#include "py/objtype.h"
#include "py/runtime.h"
#include "supervisor/shared/translate.h"
typedef struct _mp_obj_object_t {
mp_obj_base_t base;
} mp_obj_object_t;
@ -50,7 +52,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(object___init___obj, object___init__);
STATIC mp_obj_t object___new__(mp_obj_t cls) {
if (!MP_OBJ_IS_TYPE(cls, &mp_type_type) || !mp_obj_is_instance_type((mp_obj_type_t*)MP_OBJ_TO_PTR(cls))) {
mp_raise_TypeError("__new__ arg must be a user-type");
mp_raise_TypeError(translate("__new__ arg must be a user-type"));
}
// This executes only "__new__" part of instance creation.
// TODO: This won't work well for classes with native bases.

View File

@ -28,6 +28,8 @@
#include "py/runtime.h"
#include "supervisor/shared/translate.h"
/******************************************************************************/
/* range iterator */
@ -105,7 +107,7 @@ STATIC mp_obj_t range_make_new(const mp_obj_type_t *type, size_t n_args, size_t
if (n_args == 3) {
o->step = mp_obj_get_int(args[2]);
if (o->step == 0) {
mp_raise_ValueError("zero step");
mp_raise_ValueError(translate("zero step"));
}
}
}

View File

@ -31,6 +31,8 @@
#include "py/runtime.h"
#include "py/builtin.h"
#include "supervisor/shared/translate.h"
#if MICROPY_PY_BUILTINS_SET
typedef struct _mp_obj_set_t {
@ -366,7 +368,7 @@ STATIC mp_obj_t set_pop(mp_obj_t self_in) {
mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
mp_obj_t obj = mp_set_remove_first(&self->set);
if (obj == MP_OBJ_NULL) {
mp_raise_msg(&mp_type_KeyError, "pop from an empty set");
mp_raise_msg(&mp_type_KeyError, translate("pop from an empty set"));
}
return obj;
}

View File

@ -31,6 +31,8 @@
#include "py/runtime.h"
#include "py/runtime0.h"
#include "supervisor/shared/translate.h"
/******************************************************************************/
/* slice object */
@ -61,12 +63,12 @@ STATIC void slice_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
STATIC mp_obj_t slice_indices(mp_obj_t self_in, mp_obj_t length_obj) {
mp_obj_slice_t *self = MP_OBJ_TO_PTR(self_in);
if (!MP_OBJ_IS_SMALL_INT(length_obj)) {
mp_raise_TypeError("Length must be an int");
mp_raise_TypeError(translate("Length must be an int"));
}
int length = MP_OBJ_SMALL_INT_VALUE(length_obj);
if (length < 0) {
mp_raise_ValueError("Length must be non-negative");
mp_raise_ValueError(translate("Length must be non-negative"));
}
mp_obj_t indices[3] = {MP_OBJ_NEW_SMALL_INT(0), length_obj, MP_OBJ_NEW_SMALL_INT(1)};
@ -81,7 +83,7 @@ STATIC mp_obj_t slice_indices(mp_obj_t self_in, mp_obj_t length_obj) {
indices[1] = MP_OBJ_NEW_SMALL_INT(-1);
}
if (step == 0) {
mp_raise_ValueError("slice step cannot be zero");
mp_raise_ValueError(translate("slice step cannot be zero"));
}
}
for (int i = 0; i < 2; i++) {
@ -154,7 +156,7 @@ mp_obj_t mp_obj_new_slice(mp_obj_t ostart, mp_obj_t ostop, mp_obj_t ostep) {
STATIC mp_obj_t slice_make_new(const mp_obj_type_t *type,
size_t n_args, size_t n_kw, const mp_obj_t *args) {
if (type != &mp_type_slice) {
mp_raise_NotImplementedError("Cannot subclass slice");
mp_raise_NotImplementedError(translate("Cannot subclass slice"));
}
// check number of arguments
mp_arg_check_num(n_args, n_kw, 1, 3, false);

View File

@ -34,6 +34,8 @@
#include "py/runtime.h"
#include "py/stackctrl.h"
#include "supervisor/shared/translate.h"
STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_t *args, mp_obj_t dict);
STATIC mp_obj_t mp_obj_new_bytes_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf);
@ -256,7 +258,7 @@ STATIC mp_obj_t bytes_make_new(const mp_obj_type_t *type_in, size_t n_args, size
mp_int_t val = mp_obj_get_int(item);
#if MICROPY_FULL_CHECKS
if (val < 0 || val > 255) {
mp_raise_ValueError("bytes value out of range");
mp_raise_ValueError(translate("bytes value out of range"));
}
#endif
vstr_add_byte(&vstr, val);
@ -265,7 +267,7 @@ STATIC mp_obj_t bytes_make_new(const mp_obj_type_t *type_in, size_t n_args, size
return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr);
wrong_args:
mp_raise_TypeError("wrong number of arguments");
mp_raise_TypeError(translate("wrong number of arguments"));
}
// like strstr but with specified length and allows \0 bytes
@ -422,7 +424,7 @@ STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) {
mp_bound_slice_t slice;
if (!mp_seq_get_fast_slice_indexes(self_len, index, &slice)) {
mp_raise_NotImplementedError("only slices with step=1 (aka None) are supported");
mp_raise_NotImplementedError(translate("only slices with step=1 (aka None) are supported"));
}
return mp_obj_new_str_of_type(type, self_data + slice.start, slice.stop - slice.start);
}
@ -462,7 +464,7 @@ STATIC mp_obj_t str_join(mp_obj_t self_in, mp_obj_t arg) {
for (size_t i = 0; i < seq_len; i++) {
if (mp_obj_get_type(seq_items[i]) != self_type) {
mp_raise_TypeError(
"join expects a list of str/bytes objects consistent with self object");
translate("join expects a list of str/bytes objects consistent with self object"));
}
if (i > 0) {
required_len += sep_len;
@ -537,7 +539,7 @@ mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args) {
const char *sep_str = mp_obj_str_get_data(sep, &sep_len);
if (sep_len == 0) {
mp_raise_ValueError("empty separator");
mp_raise_ValueError(translate("empty separator"));
}
for (;;) {
@ -636,13 +638,13 @@ STATIC mp_obj_t str_rsplit(size_t n_args, const mp_obj_t *args) {
mp_int_t idx = splits;
if (sep == mp_const_none) {
mp_raise_NotImplementedError("rsplit(None,n)");
mp_raise_NotImplementedError(translate("rsplit(None,n)"));
} else {
size_t sep_len;
const char *sep_str = mp_obj_str_get_data(sep, &sep_len);
if (sep_len == 0) {
mp_raise_ValueError("empty separator");
mp_raise_ValueError(translate("empty separator"));
}
const byte *beg = s;
@ -708,7 +710,7 @@ STATIC mp_obj_t str_finder(size_t n_args, const mp_obj_t *args, int direction, b
out_error:
// not found
if (is_index) {
mp_raise_ValueError("substring not found");
mp_raise_ValueError(translate("substring not found"));
} else {
return MP_OBJ_NEW_SMALL_INT(-1);
}
@ -765,7 +767,7 @@ STATIC mp_obj_t str_endswith(size_t n_args, const mp_obj_t *args) {
size_t suffix_len;
const char *suffix = mp_obj_str_get_data(args[1], &suffix_len);
if (n_args > 2) {
mp_raise_NotImplementedError("start/end indices");
mp_raise_NotImplementedError(translate("start/end indices"));
}
if (suffix_len > str_len) {
@ -926,7 +928,7 @@ STATIC mp_obj_t arg_as_int(mp_obj_t arg) {
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
STATIC NORETURN void terse_str_format_value_error(void) {
mp_raise_ValueError("bad format string");
mp_raise_ValueError(translate("bad format string"));
}
#else
// define to nothing to improve coverage
@ -948,7 +950,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
terse_str_format_value_error();
} else {
mp_raise_ValueError("single '}' encountered in format string");
mp_raise_ValueError(translate("single '}' encountered in format string"));
}
}
if (*str != '{') {
@ -987,13 +989,13 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
terse_str_format_value_error();
} else if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL) {
mp_raise_ValueError("bad conversion specifier");
mp_raise_ValueError(translate("bad conversion specifier"));
} else {
if (str >= top) {
mp_raise_ValueError(
"end of format while looking for conversion specifier");
translate("end of format while looking for conversion specifier"));
} else {
mp_raise_ValueError_varg("unknown conversion specifier %c", *str);
mp_raise_ValueError_varg(translate("unknown conversion specifier %c"), *str);
}
}
}
@ -1024,14 +1026,14 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
terse_str_format_value_error();
} else {
mp_raise_ValueError("unmatched '{' in format");
mp_raise_ValueError(translate("unmatched '{' in format"));
}
}
if (*str != '}') {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
terse_str_format_value_error();
} else {
mp_raise_ValueError("expected ':' after format specifier");
mp_raise_ValueError(translate("expected ':' after format specifier"));
}
}
@ -1045,12 +1047,12 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
terse_str_format_value_error();
} else {
mp_raise_ValueError(
"can't switch from automatic field numbering to manual field specification");
translate("can't switch from automatic field numbering to manual field specification"));
}
}
field_name = str_to_int(field_name, field_name_top, &index);
if ((uint)index >= n_args - 1) {
mp_raise_IndexError("tuple index out of range");
mp_raise_IndexError(translate("tuple index out of range"));
}
arg = args[index + 1];
*arg_i = -1;
@ -1066,7 +1068,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
arg = key_elem->value;
}
if (field_name < field_name_top) {
mp_raise_NotImplementedError("attributes not supported yet");
mp_raise_NotImplementedError(translate("attributes not supported yet"));
}
} else {
if (*arg_i < 0) {
@ -1074,11 +1076,11 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
terse_str_format_value_error();
} else {
mp_raise_ValueError(
"can't switch from manual field specification to automatic field numbering");
translate("can't switch from manual field specification to automatic field numbering"));
}
}
if ((uint)*arg_i >= n_args - 1) {
mp_raise_IndexError("tuple index out of range");
mp_raise_IndexError(translate("tuple index out of range"));
}
arg = args[(*arg_i) + 1];
(*arg_i)++;
@ -1166,7 +1168,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
terse_str_format_value_error();
} else {
mp_raise_ValueError("invalid format specifier");
mp_raise_ValueError(translate("invalid format specifier"));
}
}
vstr_clear(&format_spec_vstr);
@ -1187,7 +1189,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
terse_str_format_value_error();
} else {
mp_raise_ValueError("sign not allowed in string format specifier");
mp_raise_ValueError(translate("sign not allowed in string format specifier"));
}
}
if (type == 'c') {
@ -1195,7 +1197,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
terse_str_format_value_error();
} else {
mp_raise_ValueError(
"sign not allowed with integer format specifier 'c'");
translate("sign not allowed with integer format specifier 'c'"));
}
}
}
@ -1254,7 +1256,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
terse_str_format_value_error();
} else {
mp_raise_ValueError_varg(
"unknown format code '%c' for object of type '%s'",
translate("unknown format code '%c' for object of type '%s'"),
type, mp_obj_get_type_str(arg));
}
}
@ -1326,7 +1328,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
terse_str_format_value_error();
} else {
mp_raise_ValueError_varg(
"unknown format code '%c' for object of type 'float'",
translate("unknown format code '%c' for object of type 'float'"),
type, mp_obj_get_type_str(arg));
}
}
@ -1338,7 +1340,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
terse_str_format_value_error();
} else {
mp_raise_ValueError(
"'=' alignment not allowed in string format specifier");
translate("'=' alignment not allowed in string format specifier"));
}
}
@ -1362,7 +1364,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
terse_str_format_value_error();
} else {
mp_raise_ValueError_varg(
"unknown format code '%c' for object of type 'str'",
translate("unknown format code '%c' for object of type 'str'"),
type, mp_obj_get_type_str(arg));
}
}
@ -1410,7 +1412,7 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_
// Dictionary value lookup
if (*str == '(') {
if (dict == MP_OBJ_NULL) {
mp_raise_TypeError("format requires a dict");
mp_raise_TypeError(translate("format requires a dict"));
}
arg_i = 1; // we used up the single dict argument
const byte *key = ++str;
@ -1419,7 +1421,7 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
terse_str_format_value_error();
} else {
mp_raise_ValueError("incomplete format key");
mp_raise_ValueError(translate("incomplete format key"));
}
}
++str;
@ -1477,7 +1479,7 @@ incomplete_format:
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
terse_str_format_value_error();
} else {
mp_raise_ValueError("incomplete format");
mp_raise_ValueError(translate("incomplete format"));
}
}
@ -1485,7 +1487,7 @@ incomplete_format:
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(translate("not enough arguments for format string"));
}
arg = args[arg_i++];
}
@ -1495,14 +1497,14 @@ not_enough_args:
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(translate("%%c requires 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(translate("integer required"));
}
break;
@ -1565,14 +1567,14 @@ not_enough_args:
terse_str_format_value_error();
} else {
mp_raise_ValueError_varg(
"unsupported format character '%c' (0x%x) at index %d",
translate("unsupported format character '%c' (0x%x) at index %d"),
*str, *str, str - start_str);
}
}
}
if (arg_i != n_args) {
mp_raise_TypeError("not all arguments converted during string formatting");
mp_raise_TypeError(translate("not all arguments converted during string formatting"));
}
return mp_obj_new_str_from_vstr(is_bytes ? &mp_type_bytes : &mp_type_str, &vstr);
@ -1739,7 +1741,7 @@ STATIC mp_obj_t str_partitioner(mp_obj_t self_in, mp_obj_t arg, int direction) {
GET_STR_DATA_LEN(arg, sep, sep_len);
if (sep_len == 0) {
mp_raise_ValueError("empty separator");
mp_raise_ValueError(translate("empty separator"));
}
mp_obj_t result[3];
@ -2097,11 +2099,11 @@ bool mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2) {
STATIC NORETURN void bad_implicit_conversion(mp_obj_t self_in) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError("can't convert to str implicitly");
mp_raise_TypeError(translate("can't convert to str implicitly"));
} else {
const qstr src_name = mp_obj_get_type(self_in)->name;
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
"can't convert '%q' object to %q implicitly",
translate("can't convert '%q' object to %q implicitly"),
src_name, src_name == MP_QSTR_str ? MP_QSTR_bytes : MP_QSTR_str));
}
}

View File

@ -33,12 +33,14 @@
#include "py/runtime.h"
#include "py/stream.h"
#include "supervisor/shared/translate.h"
#if MICROPY_PY_IO
#if MICROPY_CPYTHON_COMPAT
STATIC void check_stringio_is_open(const mp_obj_stringio_t *o) {
if (o->vstr == NULL) {
mp_raise_ValueError("I/O operation on closed file");
mp_raise_ValueError(translate("I/O operation on closed file"));
}
}
#else

View File

@ -32,6 +32,8 @@
#include "py/objlist.h"
#include "py/runtime.h"
#include "supervisor/shared/translate.h"
#if MICROPY_PY_BUILTINS_STR_UNICODE
STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf);
@ -129,7 +131,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s
if (MP_OBJ_IS_SMALL_INT(index)) {
i = MP_OBJ_SMALL_INT_VALUE(index);
} else if (!mp_obj_get_int_maybe(index, &i)) {
mp_raise_TypeError_varg("string indices must be integers, not %s", mp_obj_get_type_str(index));
mp_raise_TypeError_varg(translate("string indices must be integers, not %s"), mp_obj_get_type_str(index));
}
const byte *s, *top = self_data + self_len;
if (i < 0)
@ -140,7 +142,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s
if (is_slice) {
return self_data;
}
mp_raise_IndexError("string index out of range");
mp_raise_IndexError(translate("string index out of range"));
}
if (!UTF8_IS_CONT(*s)) {
++i;
@ -159,7 +161,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s
if (is_slice) {
return top;
}
mp_raise_IndexError("string index out of range");
mp_raise_IndexError(translate("string index out of range"));
}
// Then check completion
if (i-- == 0) {
@ -186,7 +188,7 @@ STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
mp_obj_t ostart, ostop, ostep;
mp_obj_slice_get(index, &ostart, &ostop, &ostep);
if (ostep != mp_const_none && ostep != MP_OBJ_NEW_SMALL_INT(1)) {
mp_raise_NotImplementedError("only slices with step=1 (aka None) are supported");
mp_raise_NotImplementedError(translate("only slices with step=1 (aka None) are supported"));
}
const byte *pstart, *pstop;

View File

@ -30,6 +30,8 @@
#include "py/objtuple.h"
#include "py/runtime.h"
#include "supervisor/shared/translate.h"
/******************************************************************************/
/* tuple */
@ -182,7 +184,7 @@ mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) {
mp_bound_slice_t slice;
if (!mp_seq_get_fast_slice_indexes(self->len, index, &slice)) {
mp_raise_NotImplementedError("only slices with step=1 (aka None) are supported");
mp_raise_NotImplementedError(translate("only slices with step=1 (aka None) are supported"));
}
mp_obj_tuple_t *res = MP_OBJ_TO_PTR(mp_obj_new_tuple(slice.stop - slice.start, NULL));
mp_seq_copy(res->items, self->items + slice.start, res->len, mp_obj_t);

View File

@ -34,6 +34,8 @@
#include "py/objtype.h"
#include "py/runtime.h"
#include "supervisor/shared/translate.h"
#if MICROPY_DEBUG_VERBOSE // print debugging info
#define DEBUG_PRINT (1)
#define DEBUG_printf DEBUG_printf
@ -353,9 +355,9 @@ mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_args, size
}
if (init_ret != mp_const_none) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError("__init__() should return None");
mp_raise_TypeError(translate("__init__() should return None"));
} else {
mp_raise_TypeError_varg("__init__() should return None, not '%s'",
mp_raise_TypeError_varg(translate("__init__() should return None, not '%s'"),
mp_obj_get_type_str(init_ret));
}
}
@ -618,7 +620,7 @@ STATIC void mp_obj_instance_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *des
// the code.
const mp_obj_t *proxy = mp_obj_property_get(member);
if (proxy[0] == mp_const_none) {
mp_raise_AttributeError("unreadable attribute");
mp_raise_AttributeError(translate("unreadable attribute"));
} else {
dest[0] = mp_call_function_n_kw(proxy[0], 1, 0, &self_in);
}
@ -863,9 +865,9 @@ mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, cons
mp_obj_t call = mp_obj_instance_get_call(self_in, member);
if (call == MP_OBJ_NULL) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError("object not callable");
mp_raise_TypeError(translate("object not callable"));
} else {
mp_raise_TypeError_varg("'%s' object is not callable",
mp_raise_TypeError_varg(translate("'%s' object is not callable"),
mp_obj_get_type_str(self_in));
}
}
@ -973,7 +975,7 @@ STATIC mp_obj_t type_make_new(const mp_obj_type_t *type_in, size_t n_args, size_
return mp_obj_new_type(mp_obj_str_get_qstr(args[0]), args[1], args[2]);
default:
mp_raise_TypeError("type takes 1 or 3 arguments");
mp_raise_TypeError(translate("type takes 1 or 3 arguments"));
}
}
@ -984,9 +986,9 @@ STATIC mp_obj_t type_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp
if (self->make_new == NULL) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError("cannot create instance");
mp_raise_TypeError(translate("cannot create instance"));
} else {
mp_raise_TypeError_varg("cannot create '%q' instances", self->name);
mp_raise_TypeError_varg(translate("cannot create '%q' instances"), self->name);
}
}
@ -1042,7 +1044,7 @@ STATIC void type_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
if (check_for_special_accessors(MP_OBJ_NEW_QSTR(attr), dest[1])) {
if (self->flags & TYPE_FLAG_IS_SUBCLASSED) {
// This class is already subclassed so can't have special accessors added
mp_raise_msg(&mp_type_AttributeError, "can't add special method to already-subclassed class");
mp_raise_msg(&mp_type_AttributeError, translate("can't add special method to already-subclassed class"));
}
self->flags |= TYPE_FLAG_HAS_SPECIAL_ACCESSORS;
}
@ -1086,16 +1088,16 @@ mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict)
mp_obj_tuple_get(bases_tuple, &bases_len, &bases_items);
for (size_t i = 0; i < bases_len; i++) {
if (!MP_OBJ_IS_TYPE(bases_items[i], &mp_type_type)) {
mp_raise_TypeError("type is not an acceptable base type");
mp_raise_TypeError(translate("type is not an acceptable base type"));
}
mp_obj_type_t *t = MP_OBJ_TO_PTR(bases_items[i]);
// 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(translate("type is not an acceptable base type"));
} else {
mp_raise_TypeError_varg(
"type '%q' is not an acceptable base type", t->name);
translate("type '%q' is not an acceptable base type"), t->name);
}
}
#if ENABLE_SPECIAL_ACCESSORS
@ -1132,7 +1134,7 @@ mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict)
#if MICROPY_MULTIPLE_INHERITANCE
o->parent = MP_OBJ_TO_PTR(bases_tuple);
#else
mp_raise_NotImplementedError("multiple inheritance not supported");
mp_raise_NotImplementedError(translate("multiple inheritance not supported"));
#endif
} else {
o->parent = MP_OBJ_TO_PTR(bases_items[0]);
@ -1159,7 +1161,7 @@ mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict)
const mp_obj_type_t *native_base;
size_t num_native_bases = instance_count_native_bases(o, &native_base);
if (num_native_bases > 1) {
mp_raise_TypeError("multiple bases have instance lay-out conflict");
mp_raise_TypeError(translate("multiple bases have instance lay-out conflict"));
}
mp_map_t *locals_map = &o->locals_dict->map;
@ -1200,7 +1202,7 @@ STATIC mp_obj_t super_make_new(const mp_obj_type_t *type_in, size_t n_args, size
// 1 argument is not yet implemented
mp_arg_check_num(n_args, n_kw, 2, 2, false);
if(!MP_OBJ_IS_TYPE(args[0], &mp_type_type)) {
mp_raise_TypeError("first argument to super() must be type");
mp_raise_TypeError(translate("first argument to super() must be type"));
}
mp_obj_super_t *o = m_new_obj(mp_obj_super_t);
*o = (mp_obj_super_t){{type_in}, args[0], args[1]};
@ -1270,7 +1272,7 @@ STATIC void super_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
if (MP_OBJ_IS_TYPE(member, &mp_type_property)) {
const mp_obj_t *proxy = mp_obj_property_get(member);
if (proxy[0] == mp_const_none) {
mp_raise_AttributeError("unreadable attribute");
mp_raise_AttributeError(translate("unreadable attribute"));
} else {
dest[0] = mp_call_function_n_kw(proxy[0], 1, 0, &self_in);
}
@ -1365,7 +1367,7 @@ STATIC mp_obj_t mp_obj_is_subclass(mp_obj_t object, mp_obj_t classinfo) {
} else if (MP_OBJ_IS_TYPE(classinfo, &mp_type_tuple)) {
mp_obj_tuple_get(classinfo, &len, &items);
} else {
mp_raise_TypeError("issubclass() arg 2 must be a class or a tuple of classes");
mp_raise_TypeError(translate("issubclass() arg 2 must be a class or a tuple of classes"));
}
for (size_t i = 0; i < len; i++) {
@ -1379,7 +1381,7 @@ STATIC mp_obj_t mp_obj_is_subclass(mp_obj_t object, mp_obj_t classinfo) {
STATIC mp_obj_t mp_builtin_issubclass(mp_obj_t object, mp_obj_t classinfo) {
if (!MP_OBJ_IS_TYPE(object, &mp_type_type)) {
mp_raise_TypeError("issubclass() arg 1 must be a class");
mp_raise_TypeError(translate("issubclass() arg 1 must be a class"));
}
return mp_obj_is_subclass(object, classinfo);
}

View File

@ -39,6 +39,8 @@
#include "py/objstr.h"
#include "py/builtin.h"
#include "supervisor/shared/translate.h"
#if MICROPY_ENABLE_COMPILER
#define RULE_ACT_ARG_MASK (0x0f)
@ -721,7 +723,7 @@ STATIC bool fold_constants(parser_t *parser, uint8_t rule_id, size_t num_args) {
mp_obj_t value;
if (!mp_parse_node_get_int_maybe(pn_value, &value)) {
mp_obj_t exc = mp_obj_new_exception_msg(&mp_type_SyntaxError,
"constant must be an integer");
translate("constant must be an integer"));
mp_obj_exception_add_traceback(exc, parser->lexer->source_name,
((mp_parse_node_struct_t*)pn1)->source_line, MP_QSTR_NULL);
nlr_raise(exc);
@ -863,7 +865,7 @@ mp_parse_tree_t mp_parse(mp_lexer_t *lex, mp_parse_input_kind_t input_kind) {
}
}
if (parser.rule_stack == NULL || parser.result_stack == NULL) {
mp_raise_msg(&mp_type_MemoryError, "Unable to init parser");
mp_raise_msg(&mp_type_MemoryError, translate("Unable to init parser"));
}
parser.lexer = lex;
@ -1165,13 +1167,13 @@ mp_parse_tree_t mp_parse(mp_lexer_t *lex, mp_parse_input_kind_t input_kind) {
mp_obj_t exc;
if (lex->tok_kind == MP_TOKEN_INDENT) {
exc = mp_obj_new_exception_msg(&mp_type_IndentationError,
"unexpected indent");
translate("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");
translate("unindent does not match any outer indentation level"));
} else {
exc = mp_obj_new_exception_msg(&mp_type_SyntaxError,
"invalid syntax");
translate("invalid syntax"));
}
// add traceback to give info about file name and location
// we don't have a 'block' name, so just pass the NULL qstr to indicate this

View File

@ -32,6 +32,8 @@
#include "py/parsenum.h"
#include "py/smallint.h"
#include "supervisor/shared/translate.h"
#if MICROPY_PY_BUILTINS_FLOAT
#include <math.h>
#endif
@ -55,7 +57,7 @@ mp_obj_t mp_parse_num_integer(const char *restrict str_, size_t len, int base, m
// check radix base
if ((base != 0 && base < 2) || base > 36) {
// this won't be reached if lex!=NULL
mp_raise_ValueError("int() arg 2 must be >= 2 and <= 36");
mp_raise_ValueError(translate("int() arg 2 must be >= 2 and <= 36"));
}
// skip leading space

View File

@ -34,6 +34,8 @@
#include "py/persistentcode.h"
#include "py/bc.h"
#include "supervisor/shared/translate.h"
#if MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE
#include "py/smallint.h"
@ -218,9 +220,7 @@ mp_raw_code_t *mp_raw_code_load(mp_reader_t *reader) {
|| header[1] != MPY_VERSION
|| header[2] != MPY_FEATURE_FLAGS
|| header[3] > mp_small_int_bits()) {
// TODO(tannewt): Restore the generic error after we move folks to 2.0.0.
// mp_raise_ValueError("incompatible .mpy file");
mp_raise_ValueError("Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/mpy-update for more info.");
mp_raise_ValueError(translate("Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/mpy-update for more info."));
}
mp_raw_code_t *rc = load_raw_code(reader);
reader->close(reader->data);
@ -323,7 +323,7 @@ STATIC void save_bytecode_qstrs(mp_print_t *print, const byte *ip, const byte *i
STATIC void save_raw_code(mp_print_t *print, mp_raw_code_t *rc) {
if (rc->kind != MP_CODE_BYTECODE) {
mp_raise_ValueError("can only save bytecode");
mp_raise_ValueError(translate("can only save bytecode"));
}
// save bytecode

View File

@ -47,6 +47,8 @@
#include "py/stackctrl.h"
#include "py/gc.h"
#include "supervisor/shared/translate.h"
#if MICROPY_DEBUG_VERBOSE // print debugging info
#define DEBUG_PRINT (1)
#define DEBUG_printf DEBUG_printf
@ -201,10 +203,10 @@ mp_obj_t mp_load_global(qstr qst) {
elem = mp_map_lookup((mp_map_t*)&mp_module_builtins_globals.map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP);
if (elem == NULL) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_msg(&mp_type_NameError, "name not defined");
mp_raise_msg(&mp_type_NameError, translate("name not defined"));
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_NameError,
"name '%q' is not defined", qst));
translate("name '%q' is not defined"), qst));
}
}
}
@ -299,10 +301,10 @@ mp_obj_t mp_unary_op(mp_unary_op_t op, mp_obj_t arg) {
}
}
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError("unsupported type for operator");
mp_raise_TypeError(translate("unsupported type for operator"));
} else {
mp_raise_TypeError_varg(
"unsupported type for %q: '%s'",
translate("unsupported type for %q: '%s'"),
mp_unary_op_method_name[op], mp_obj_get_type_str(arg));
}
}
@ -391,7 +393,7 @@ mp_obj_t mp_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
case MP_BINARY_OP_INPLACE_LSHIFT: {
if (rhs_val < 0) {
// negative shift not allowed
mp_raise_ValueError("negative shift count");
mp_raise_ValueError(translate("negative shift count"));
} else if (rhs_val >= (mp_int_t)BITS_PER_WORD || lhs_val > (MP_SMALL_INT_MAX >> rhs_val) || lhs_val < (MP_SMALL_INT_MIN >> rhs_val)) {
// left-shift will overflow, so use higher precision integer
lhs = mp_obj_new_int_from_ll(lhs_val);
@ -406,7 +408,7 @@ mp_obj_t mp_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
case MP_BINARY_OP_INPLACE_RSHIFT:
if (rhs_val < 0) {
// negative shift not allowed
mp_raise_ValueError("negative shift count");
mp_raise_ValueError(translate("negative shift count"));
} else {
// standard precision is enough for right-shift
if (rhs_val >= (mp_int_t)BITS_PER_WORD) {
@ -481,7 +483,7 @@ mp_obj_t mp_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
lhs = mp_obj_new_float(lhs_val);
goto generic_binary_op;
#else
mp_raise_ValueError("negative power with no float support");
mp_raise_ValueError(translate("negative power with no float support"));
#endif
} else {
mp_int_t ans = 1;
@ -606,15 +608,15 @@ generic_binary_op:
unsupported_op:
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError("unsupported type for operator");
mp_raise_TypeError(translate("unsupported type for operator"));
} else {
mp_raise_TypeError_varg(
"unsupported types for %q: '%s', '%s'",
translate("unsupported types for %q: '%s', '%s'"),
mp_binary_op_method_name[op], mp_obj_get_type_str(lhs), mp_obj_get_type_str(rhs));
}
zero_division:
mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero");
mp_raise_msg(&mp_type_ZeroDivisionError, translate("division by zero"));
}
mp_obj_t mp_call_function_0(mp_obj_t fun) {
@ -648,9 +650,9 @@ mp_obj_t mp_call_function_n_kw(mp_obj_t fun_in, size_t n_args, size_t n_kw, cons
}
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError("object not callable");
mp_raise_TypeError(translate("object not callable"));
} else {
mp_raise_TypeError_varg("'%s' object is not callable", mp_obj_get_type_str(fun_in));
mp_raise_TypeError_varg(translate("'%s' object is not callable"), mp_obj_get_type_str(fun_in));
}
}
@ -876,16 +878,16 @@ void mp_unpack_sequence(mp_obj_t seq_in, size_t num, mp_obj_t *items) {
too_short:
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_ValueError("wrong number of values to unpack");
mp_raise_ValueError(translate("wrong number of values to unpack"));
} else {
mp_raise_ValueError_varg("need more than %d values to unpack",
mp_raise_ValueError_varg(translate("need more than %d values to unpack"),
(int)seq_len);
}
too_long:
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_ValueError("wrong number of values to unpack");
mp_raise_ValueError(translate("wrong number of values to unpack"));
} else {
mp_raise_ValueError_varg("too many values to unpack (expected %d)",
mp_raise_ValueError_varg(translate("too many values to unpack (expected %d)"),
(int)num);
}
}
@ -940,9 +942,9 @@ void mp_unpack_ex(mp_obj_t seq_in, size_t num_in, mp_obj_t *items) {
too_short:
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_ValueError("wrong number of values to unpack");
mp_raise_ValueError(translate("wrong number of values to unpack"));
} else {
mp_raise_ValueError_varg("need more than %d values to unpack",
mp_raise_ValueError_varg(translate("need more than %d values to unpack"),
(int)seq_len);
}
}
@ -979,9 +981,9 @@ STATIC mp_obj_t checked_fun_call(mp_obj_t self_in, size_t n_args, size_t n_kw, c
const mp_obj_type_t *arg0_type = mp_obj_get_type(args[0]);
if (arg0_type != self->type) {
if (MICROPY_ERROR_REPORTING != MICROPY_ERROR_REPORTING_DETAILED) {
mp_raise_TypeError("argument has wrong type");
mp_raise_TypeError(translate("argument has wrong type"));
} else {
mp_raise_TypeError_varg("argument should be a '%q' not a '%q'",
mp_raise_TypeError_varg(translate("argument should be a '%q' not a '%q'"),
self->type->name, arg0_type->name);
}
}
@ -1060,7 +1062,7 @@ void mp_convert_member_lookup(mp_obj_t self, const mp_obj_type_t *type, mp_obj_t
// the code.
const mp_obj_t *proxy = mp_obj_property_get(member);
if (proxy[0] == mp_const_none) {
mp_raise_AttributeError("unreadable attribute");
mp_raise_AttributeError(translate("unreadable attribute"));
} else {
dest[0] = mp_call_function_n_kw(proxy[0], 1, 0, &self);
}
@ -1118,16 +1120,16 @@ void mp_load_method(mp_obj_t base, qstr attr, mp_obj_t *dest) {
if (dest[0] == MP_OBJ_NULL) {
// no attribute/method called attr
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_AttributeError("no such attribute");
mp_raise_AttributeError(translate("no such attribute"));
} else {
// following CPython, we give a more detailed error message for type objects
if (MP_OBJ_IS_TYPE(base, &mp_type_type)) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_AttributeError,
"type object '%q' has no attribute '%q'",
translate("type object '%q' has no attribute '%q'"),
((mp_obj_type_t*)MP_OBJ_TO_PTR(base))->name, attr));
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_AttributeError,
"'%s' object has no attribute '%q'",
translate("'%s' object has no attribute '%q'"),
mp_obj_get_type_str(base), attr));
}
}
@ -1192,10 +1194,10 @@ void mp_store_attr(mp_obj_t base, qstr attr, mp_obj_t value) {
#endif
}
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_AttributeError("no such attribute");
mp_raise_AttributeError(translate("no such attribute"));
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_AttributeError,
"'%s' object has no attribute '%q'",
translate("'%s' object has no attribute '%q'"),
mp_obj_get_type_str(base), attr));
}
}
@ -1233,10 +1235,10 @@ mp_obj_t mp_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) {
// object not iterable
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError("object not iterable");
mp_raise_TypeError(translate("object not iterable"));
} else {
mp_raise_TypeError_varg(
"'%s' object is not iterable", mp_obj_get_type_str(o_in));
translate("'%s' object is not iterable"), mp_obj_get_type_str(o_in));
}
}
@ -1255,9 +1257,9 @@ mp_obj_t mp_iternext_allow_raise(mp_obj_t o_in) {
return mp_call_method_n_kw(0, 0, dest);
} else {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError("object not an iterator");
mp_raise_TypeError(translate("object not an iterator"));
} else {
mp_raise_TypeError_varg("'%s' object is not an iterator",
mp_raise_TypeError_varg(translate("'%s' object is not an iterator"),
mp_obj_get_type_str(o_in));
}
}
@ -1291,9 +1293,9 @@ mp_obj_t mp_iternext(mp_obj_t o_in) {
}
} else {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError("object not an iterator");
mp_raise_TypeError(translate("object not an iterator"));
} else {
mp_raise_TypeError_varg("'%s' object is not an iterator",
mp_raise_TypeError_varg(translate("'%s' object is not an iterator"),
mp_obj_get_type_str(o_in));
}
}
@ -1396,7 +1398,7 @@ mp_obj_t mp_make_raise_obj(mp_obj_t o) {
return o;
} else {
// o cannot be used as an exception, so return a type error (which will be raised by the caller)
return mp_obj_new_exception_msg(&mp_type_TypeError, "exceptions must derive from BaseException");
return mp_obj_new_exception_msg(&mp_type_TypeError, translate("exceptions must derive from BaseException"));
}
}
@ -1425,7 +1427,7 @@ mp_obj_t mp_import_from(mp_obj_t module, qstr name) {
if (dest[1] != MP_OBJ_NULL) {
// Hopefully we can't import bound method from an object
import_error:
mp_raise_msg_varg(&mp_type_ImportError, "cannot import name %q", name);
mp_raise_msg_varg(&mp_type_ImportError, translate("cannot import name %q"), name);
}
if (dest[0] != MP_OBJ_NULL) {
@ -1530,11 +1532,11 @@ NORETURN void m_malloc_fail(size_t num_bytes) {
DEBUG_printf("memory allocation failed, allocating %u bytes\n", (uint)num_bytes);
#if MICROPY_ENABLE_GC
if (gc_is_locked()) {
mp_raise_msg(&mp_type_MemoryError, "memory allocation failed, heap is locked");
mp_raise_msg(&mp_type_MemoryError, translate("memory allocation failed, heap is locked"));
}
#endif
mp_raise_msg_varg(&mp_type_MemoryError,
"memory allocation failed, allocating %u bytes", (uint)num_bytes);
translate("memory allocation failed, allocating %u bytes"), (uint)num_bytes);
}
NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg) {
@ -1604,7 +1606,6 @@ NORETURN void mp_raise_NotImplementedError(const char *msg) {
#if MICROPY_STACK_CHECK || MICROPY_ENABLE_PYSTACK
NORETURN void mp_raise_recursion_depth(void) {
nlr_raise(mp_obj_new_exception_arg1(&mp_type_RuntimeError,
MP_OBJ_NEW_QSTR(MP_QSTR_maximum_space_recursion_space_depth_space_exceeded)));
mp_raise_RuntimeError(translate("maximum recursion depth exceeded"));
}
#endif

View File

@ -28,6 +28,7 @@
#include <string.h>
#include "py/runtime.h"
#include "supervisor/shared/translate.h"
// Helpers for sequence types
@ -53,7 +54,7 @@ bool mp_seq_get_fast_slice_indexes(mp_uint_t len, mp_obj_t slice, mp_bound_slice
if (ostep != mp_const_none && ostep != MP_OBJ_NEW_SMALL_INT(1)) {
indexes->step = mp_obj_get_int(ostep);
if (indexes->step == 0) {
mp_raise_ValueError("slice step cannot be zero");
mp_raise_ValueError(translate("slice step cannot be zero"));
}
} else {
indexes->step = 1;
@ -260,7 +261,7 @@ mp_obj_t mp_seq_index_obj(const mp_obj_t *items, size_t len, size_t n_args, cons
}
}
mp_raise_ValueError("object not in sequence");
mp_raise_ValueError(translate("object not in sequence"));
}
mp_obj_t mp_seq_count_obj(const mp_obj_t *items, size_t len, mp_obj_t value) {

View File

@ -31,6 +31,7 @@
#include "py/objstr.h"
#include "py/stream.h"
#include "py/runtime.h"
#include "supervisor/shared/translate.h"
// This file defines generic Python stream read/write methods which
// dispatch to the underlying stream interface of an object.
@ -92,7 +93,7 @@ const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags) {
|| ((flags & MP_STREAM_OP_WRITE) && stream_p->write == NULL)
|| ((flags & MP_STREAM_OP_IOCTL) && stream_p->ioctl == NULL)) {
// CPython: io.UnsupportedOperation, OSError subclass
mp_raise_msg(&mp_type_OSError, "stream operation not supported");
mp_raise_msg(&mp_type_OSError, translate("stream operation not supported"));
}
return stream_p;
}

View File

@ -97,6 +97,6 @@ void assert_pin_free(const mcu_pin_obj_t* pin) {
qstr name;
get_pin_name(pin, &package, &module, &name);
mp_raise_ValueError_varg("%q in use", name);
mp_raise_ValueError_varg(translate("%q in use"), name);
}
}