diff options
| author | Dan Halbert <halbert@halwitz.org> | 2021-02-15 20:03:53 -0500 |
|---|---|---|
| committer | Dan Halbert <halbert@halwitz.org> | 2021-02-15 20:03:53 -0500 |
| commit | 93d788543c2f1f688a9e74d9984f63948e76a598 (patch) | |
| tree | 6cdce3c17a161d42199bd9a925774bc891ff9180 /py | |
| parent | d54b5861a30b1b1a352e1c22fc67e729ec95390d (diff) | |
| parent | 5ccbb0be62bdf3731421dab05e8ec3524158c274 (diff) | |
Merge remote-tracking branch 'adafruit/main' into secondary-cdc
Diffstat (limited to 'py')
| -rw-r--r-- | py/builtinevex.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/py/builtinevex.c b/py/builtinevex.c index ade12d39d..cff57c413 100644 --- a/py/builtinevex.c +++ b/py/builtinevex.c @@ -132,17 +132,18 @@ STATIC mp_obj_t eval_exec_helper(size_t n_args, const mp_obj_t *args, mp_parse_i } #endif - size_t str_len; - const char *str = mp_obj_str_get_data(args[0], &str_len); + // Extract the source code. + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ); // create the lexer // MP_PARSE_SINGLE_INPUT is used to indicate a file input mp_lexer_t *lex; if (MICROPY_PY_BUILTINS_EXECFILE && parse_input_kind == MP_PARSE_SINGLE_INPUT) { - lex = mp_lexer_new_from_file(str); + lex = mp_lexer_new_from_file(bufinfo.buf); parse_input_kind = MP_PARSE_FILE_INPUT; } else { - lex = mp_lexer_new_from_str_len(MP_QSTR__lt_string_gt_, str, str_len, 0); + lex = mp_lexer_new_from_str_len(MP_QSTR__lt_string_gt_, bufinfo.buf, bufinfo.len, 0); } return mp_parse_compile_execute(lex, parse_input_kind, globals, locals); |
