8000 Merge branch 'main' into getpass · domdfcoding/circuitpython@93c9d59 · GitHub
[go: up one dir, main page]

Skip to content

Commit 93c9d59

Browse files
committed
Merge branch 'main' into getpass
2 parents 51f8603 + 3495cc1 commit 93c9d59

File tree

35 files changed

+793
-361
lines changed

35 files changed

+793
-361
lines changed

docs/redirects.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ shared-bindings/ustack/__init__.rst shared-bindings/ustack/
152152
shared-bindings/vectorio/Circle.rst shared-bindings/vectorio/#vectorio.Circle
153153
shared-bindings/vectorio/Polygon.rst shared-bindings/vectorio/#vectorio.Polygon
154154
shared-bindings/vectorio/Rectangle.rst shared-bindings/vectorio/#vectorio.Rectangle
155-
shared-bindings/vectorio/VectorShape.rst shared-bindings/vectorio/#vectorio.VectorShape
156155
shared-bindings/vectorio/__init__.rst shared-bindings/vectorio/
157156
shared-bindings/watchdog/WatchDogMode.rst shared-bindings/watchdog/#watchdog.WatchDogMode
158157
shared-bindings/watchdog/WatchDogTimer.rst shared-bindings/watchdog/#watchdog.WatchDogTimer

locale/circuitpython.pot

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ msgid ""
3535
"https://github.com/adafruit/circuitpython/issues\n"
3636
msgstr ""
3737

38-
#: py/obj.c shared-module/traceback/__init__.c
38+
#: py/obj.c
3939
msgid " File \"%q\""
4040
msgstr ""
4141

42-
#: py/obj.c shared-module/traceback/__init__.c
42+
#: py/obj.c
4343
msgid " File \"%q\", line %d"
4444
msgstr ""
4545

@@ -318,11 +318,15 @@ msgstr ""
318318
msgid "'yield' outside function"
319319
msgstr ""
320320

321+
#: shared-module/vectorio/VectorShape.c
322+
msgid "(x,y) integers required"
323+
msgstr ""
324+
321325
#: py/compile.c
322326
msgid "*x must be assignment target"
323327
msgstr ""
324328

325-
#: py/obj.c shared-module/traceback/__init__.c
329+
#: py/obj.c
326330
msgid ", in %q\n"
327331
msgstr ""
328332

@@ -2211,7 +2215,7 @@ msgstr ""
22112215
msgid "Touch alarms not available"
22122216
msgstr ""
22132217

2214-
#: py/obj.c shared-module/traceback/__init__.c
2218+
#: py/obj.c
22152219
msgid "Traceback (most recent call last):\n"
22162220
msgstr ""
22172221

@@ -3453,10 +3457,6 @@ msgstr ""
34533457
msgid "lhs and rhs should be compatible"
34543458
msgstr ""
34553459

3456-
#: shared-bindings/traceback/__init__.c
3457-
msgid "limit should be an int"
3458-
msgstr ""
3459-
34603460
#: py/emitnative.c
34613461
msgid "local '%q' has type '%q' but source is '%q'"
34623462
msgstr ""
@@ -4314,7 +4314,7 @@ msgid "unreadable attribute"
43144314
msgstr ""
43154315

43164316
#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c
4317-
#: shared-module/vectorio/Polygon.c
4317+
#: shared-module/vectorio/Polygon.c shared-module/vectorio/VectorShape.c
43184318
msgid "unsupported %q type"
43194319
msgstr ""
43204320

locale/pt_BR.po

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ msgstr ""
66
"Project-Id-Version: PACKAGE VERSION\n"
77
"Report-Msgid-Bugs-To: \n"
88
"POT-Creation-Date: 2021-01-04 12:55-0600\n"
9-
"PO-Revision-Date: 2021-07-24 15:35+0000\n"
9+
"PO-Revision-Date: 2021-08-08 05:33+0000\n"
1010
"Last-Translator: Wellington Terumi Uemura <wellingtonuemura@gmail.com>\n"
1111
"Language-Team: \n"
1212
"Language: pt_BR\n"
1313
"MIME-Version: 1.0\n"
1414
"Content-Type: text/plain; charset=UTF-8\n"
1515
"Content-Transfer-Encoding: 8bit\n"
1616
"Plural-Forms: nplurals=2; plural=n > 1;\n"
17-
"X-Generator: Weblate 4.7.2-dev\n"
17+
"X-Generator: Weblate 4.8-dev\n"
1818

1919
#: main.c
2020
msgid ""
@@ -3164,7 +3164,7 @@ msgstr "o arquivo deve ser um arquivo aberto no modo byte"
31643164

31653165
#: shared-bindings/traceback/__init__.c
31663166
msgid "file write is not available"
3167-
msgstr ""
3167+
msgstr "a gravação de arquivos não está disponível"
31683168

31693169
#: shared-bindings/storage/__init__.c
31703170
msgid "filesystem must provide mount method"
@@ -3456,7 +3456,7 @@ msgstr "element_size %d é inválido, deve ser, 1, 2, ou 4"
34563456

34573457
#: shared-bindings/traceback/__init__.c
34583458
msgid "invalid exception"
3459-
msgstr ""
3459+
msgstr "exceção inválida"
34603460

34613461
#: extmod/modframebuf.c
34623462
msgid "invalid format"
@@ -3497,7 +3497,7 @@ msgstr "sintaxe inválida para o número"
34973497

34983498
#: py/objexcept.c shared-bindings/traceback/__init__.c
34993499
msgid "invalid traceback"
3500-
msgstr ""
3500+
msgstr "rastreamento inválido"
35013501

35023502
#: py/objtype.c
35033503
msgid "issubclass() arg 1 must be a class"
@@ -3548,7 +3548,7 @@ msgstr "o lhs e rhs devem ser compatíveis"
35483548

35493549
#: shared-bindings/traceback/__init__.c
35503550
msgid "limit should be an int"
3551-
msgstr ""
3551+
msgstr "o limite deve ser um inteiro"
35523552

35533553
#: py/emitnative.c
35543554
msgid "local '%q' has type '%q' but source is '%q'"

ports/atmel-samd/boards/grandcentral_m4_express/pins.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
5252
{ MP_OBJ_NEW_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PB22) },
5353
{ MP_OBJ_NEW_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PB23) },
5454
{ MP_OBJ_NEW_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PB00) },
55+
56+
{ MP_OBJ_NEW_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PB01) },
5557
{ MP_OBJ_NEW_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PB01) },
5658

5759
{ MP_OBJ_NEW_QSTR(MP_QSTR_TX3), MP_ROM_PTR(&pin_PB16) },

ports/esp32s2/boards/atmegazero_esp32s2/pins.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
6464
{ MP_ROM_QSTR(MP_QSTR_DAC1), MP_ROM_PTR(&pin_GPIO17) },
6565
{ MP_ROM_QSTR(MP_QSTR_DAC2), MP_ROM_PTR(&pin_GPIO18) },
6666

67-
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO35) },
67+
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) },
6868
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) },
69-
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO37) },
69+
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) },
7070

7171
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO40) },
7272

py/builtinhelp.c

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,7 @@ STATIC void mp_help_print_modules(void) {
131131

132132
#if MICROPY_ENABLE_EXTERNAL_IMPORT
133133
// let the user know there may be other modules available from the filesystem
134-
const compressed_string_t *compressed = translate("Plus any modules on the filesystem\n");
135-
char decompressed[decompress_length(compressed)];
136-
decompress(compressed, decompressed);
137-
mp_print_str(MP_PYTHON_PRINTER, decompressed);
134+
mp_printf(MP_PYTHON_PRINTER, "%S", translate("Plus any modules on the filesystem\n"));
138135
#endif
139136
}
140137
#endif
@@ -150,18 +147,10 @@ STATIC void mp_help_print_obj(const mp_obj_t obj) {
150147
const mp_obj_type_t *type = mp_obj_get_type(obj);
151148

152149
// try to print something sensible about the given object
153-
const compressed_string_t *compressed = translate("object ");
154-
char decompressed_object[decompress_length(compressed)];
155-
decompress(compressed, decompressed_object);
156-
157-
mp_print_str(MP_PYTHON_PRINTER, decompressed_object);
150+
mp_cprintf(MP_PYTHON_PRINTER, translate("object "));
158151
mp_obj_print(obj, PRINT_STR);
159152

160-
compressed = translate(" is of type %q\n");
161-
char decompressed_typestring[decompress_length(compressed)];
162-
decompress(compressed, decompressed_typestring);
163-
164-
mp_printf(MP_PYTHON_PRINTER, decompressed_typestring, type->name);
153+
mp_cprintf(MP_PYTHON_PRINTER, translate(" is of type %q\n"), type->name);
165154

166155
mp_map_t *map = NULL;
167156
if (type == &mp_type_module) {
@@ -186,11 +175,9 @@ STATIC void mp_help_print_obj(const mp_obj_t obj) {
186175
STATIC mp_obj_t mp_builtin_help(size_t n_args, const mp_obj_t *args) {
187176
if (n_args == 0) {
188177
// print a general help message. Translate only works on single strings on one line.
189-
const compressed_string_t *compressed =
190-
translate("Welcome to Adafruit CircuitPython %s!\n\nPlease visit learn.adafruit.com/category/circuitpython for project guides.\n\nTo list built-in modules please do `help(\"modules\")`.\n");
191-
char decompressed[decompress_length(compressed)];
192-
decompress(compressed, decompressed);
193-
mp_printf(MP_PYTHON_PRINTER, decompressed, MICROPY_GIT_TAG);
178+
mp_cprintf(MP_PYTHON_PRINTER,
179+
translate("Welcome to Adafruit CircuitPython %s!\n\nPlease visit learn.adafruit.com/category/circuitpython for project guides.\n\nTo list built-in modules please do `help(\"modules\")`.\n"),
180+
MICROPY_GIT_TAG);
194181
} else {
195182
// try to print something sensible about the given object
196183
mp_help_print_obj(args[0]);

py/mpprint.c

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,13 @@ int mp_print_float(const mp_print_t *print, mp_float_t f, char fmt, int flags, c
376376
}
377377
#endif
378378

379+
static int print_str_common(const mp_print_t *print, const char *str, int prec, size_t len, int flags, int fill, int width) {
380+
if (prec >= 0 && (size_t)prec < len) {
381+
len = prec;
382+
}
383+
return mp_print_strn(print, str, len, flags, fill, width);
384+
}
385+
379386
int mp_printf(const mp_print_t *print, const char *fmt, ...) {
380387
va_list ap;
381388
va_start(ap, fmt);
@@ -484,19 +491,24 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args) {
484491
qstr qst = va_arg(args, qstr);
485492
size_t len;
486493
const char *str = (const char *)qstr_data(qst, &len);
487-
if (prec >= 0 && (size_t)prec < len) {
488-
len = prec;
489-
}
490-
chrs += mp_print_strn(print, str, len, flags, fill, width);
494+
chrs += print_str_common(print, str, prec, len, flags, fill, width);
495+
break;
496+
}
497+
case 'S': {
498+
compressed_string_t *arg = va_arg(args, compressed_string_t *);
499+
size_t len_with_nul = decompress_length(arg);
500+
size_t len = len_with_nul - 1;
501+
char str[len_with_nul];
502+
decompress(arg, str);
503+
chrs += print_str_common(print, str, prec, len, flags, fill, width);
491504
break;
492505
}
493506
case 's': {
494507
const char *str = va_arg(args, const char *);
495508
#ifndef NDEBUG
496509
// With debugging enabled, catch printing of null string pointers
497-
if (prec != 0 && str == NULL) {
498-
chrs += mp_print_strn(print, "(null)", 6, flags, fill, width);
499-
break;
510+
if (str == NULL) {
511+
str = "(null)";
500512
}
501513
#endif
502514
size_t len = strlen(str);
@@ -574,3 +586,19 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args) {
574586
}
575587
return chrs;
576588
}
589+
590+
int mp_cprintf(const mp_print_t *print, const compressed_string_t *compressed_fmt, ...) {
591+
va_list ap;
592+
va_start(ap, compressed_fmt);
593+
int ret = mp_vcprintf(print, compressed_fmt, ap);
594+
va_end(ap);
595+
return ret;
596+
}
597+
598+
int mp_vcprintf(const mp_print_t *print, const compressed_string_t *compressed_fmt, va_list args) {
599+
char fmt[decompress_length(compressed_fmt)];
600+
// TODO: Optimise this to format-while-decompressing (and not require the temp stack space).
601+
decompress(compressed_fmt, fmt);
602+
603+
return mp_vprintf(print, fmt, args);
604+
}

py/mpprint.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,10 @@ int mp_printf(const mp_print_t *print, const char *fmt, ...);
7171
int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args);
7272
#endif
7373

74+
struct compressed_string;
75+
int mp_cprintf(const mp_print_t *print, const struct compressed_string *compressed_fmt, ...);
76+
#ifdef va_start
77+
int mp_vcprintf(const mp_print_t *print, const struct compressed_string *compressed_fmt, va_list args);
78+
#endif
79+
7480
#endif // MICROPY_INCLUDED_PY_MPPRINT_H

py/obj.c

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -143,41 +143,55 @@ void mp_obj_print(mp_obj_t o_in, mp_print_kind_t kind) {
143143
}
144144

145145
// helper function to print an exception with traceback
146-
void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc) {
146+
void mp_obj_print_exception_with_limit(const mp_print_t *print, mp_obj_t exc, mp_int_t limit) {
147147
if (mp_obj_is_exception_instance(exc) && stack_ok()) {
148148
size_t n, *values;
149149
mp_obj_exception_get_traceback(exc, &n, &values);
150150
if (n > 0) {
151151
assert(n % 3 == 0);
152-
// Decompress the format strings
153-
const compressed_string_t *traceback = MP_ERROR_TEXT("Traceback (most recent call last):\n");
154-
char decompressed[decompress_length(traceback)];
155-
decompress(traceback, decompressed);
156152
#if MICROPY_ENABLE_SOURCE_LINE
157153
const compressed_string_t *frame = MP_ERROR_TEXT(" File \"%q\", line %d");
158154
#else
159155
const compressed_string_t *frame = MP_ERROR_TEXT(" File \"%q\"");
160156
#endif
161-
char decompressed_frame[decompress_length(frame)];
162-
decompress(frame, decompressed_frame);
163157
const compressed_string_t *block_fmt = MP_ERROR_TEXT(", in %q\n");
164-
char decompressed_block[decompress_length(block_fmt)];
165-
decompress(block_fmt, decompressed_block);
158+
159+
// Set traceback formatting
160+
// Default: Print full traceback
161+
limit = limit * 3;
162+
mp_int_t i = n - 3, j;
163+
if (limit > 0) {
164+
// Print upto limit traceback
165+
// entries from caller's frame
166+
if ((unsigned)limit > n) {
167+
limit = n;
168+
}
169+
limit = n - limit;
170+
} else if (limit < 0) {
171+
// Print upto limit traceback
172+
// entries from last
173+
if ((unsigned)-limit > n) {
174+
limit = -n;
175+
}
176+
i = 0, limit = limit + 3;
177+
}
166178

167179
// Print the traceback
168-
mp_print_str(print, decompressed);
169-
for (int i = n - 3; i >= 0; i -= 3) {
180+
mp_cprintf(print, MP_ERROR_TEXT("Traceback (most recent call last):\n"));
181+
182+
for (; i >= limit; i -= 3) {
183+
j = (i < 0) ? -i : i;
170184
#if MICROPY_ENABLE_SOURCE_LINE
171-
mp_printf(print, decompressed_frame, values[i], (int)values[i + 1]);
185+
mp_cprintf(print, frame, values[j], (int)values[j + 1]);
172186
#else
173-
mp_printf(print, decompressed_frame, values[i]);
187+
mp_cprintf(print, frame, values[j]);
174188
#endif
175-
// the block name can be NULL if it's unknown
176-
qstr block = values[i + 2];
189+
// The block name can be NULL if it's unknown
190+
qstr block = values[j + 2];
177191
if (block == MP_QSTRnull) {
178192
mp_print_str(print, "\n");
179193
} else {
180-
mp_printf(print, decompressed_block, block);
194+
mp_cprintf(print, block_fmt, block);
181195
}
182196
}
183197
}
@@ -186,6 +200,10 @@ void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc) {
186200
mp_print_str(print, "\n");
187201
}
188202

203+
void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc) {
204+
mp_obj_print_exception_with_limit(print, exc, 0);
205+
}
206+
189207
bool PLACE_IN_ITCM(mp_obj_is_true)(mp_obj_t arg) {
190208
if (arg == mp_const_false) {
191209
return 0;

py/obj.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,7 @@ mp_obj_t mp_obj_cast_to_native_base(mp_obj_t self_in, mp_const_obj_t native_type
888888
void mp_obj_print_helper(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind);
889889
void mp_obj_print(mp_obj_t o, mp_print_kind_t kind);
890890
void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc);
891+
void mp_obj_print_exception_with_limit(const mp_print_t *print, mp_obj_t exc, mp_int_t limit);
891892

892893
bool mp_obj_is_true(mp_obj_t arg);
893894
bool mp_obj_is_callable(mp_obj_t o_in);

py/objexcept.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,12 +465,9 @@ mp_obj_t mp_obj_new_exception_msg_vlist(const mp_obj_type_t *exc_type, const com
465465
o_str->data = NULL;
466466
} else {
467467
// We have some memory to format the string.
468-
// TODO: Optimise this to format-while-decompressing (and not require the temp stack space).
469468
struct _exc_printer_t exc_pr = {!used_emg_buf, o_str_alloc, 0, o_str_buf};
470469
mp_print_t print = {&exc_pr, exc_add_strn};
471-
char fmt_decompressed[decompress_length(fmt)];
472-
decompress(fmt, fmt_decompressed);
473-
mp_vprintf(&print, fmt_decompressed, ap);
470+
mp_vcprintf(&print, fmt, ap);
474471
exc_pr.buf[exc_pr.len] = '\0';
475472
o_str->len = exc_pr.len;
476473
o_str->data = exc_pr.buf;

0 commit comments

Comments
 (0)
0