8000 Merge pull request #4206 from iot49/cp-exec · jun2sak/circuitpython@91b137e · GitHub
[go: up one dir, main page]

Skip to content

Commit 91b137e

Browse files
authored
Merge pull request adafruit#4206 from iot49/cp-exec
memoryview is valid argument to exec
2 parents 766e79a + f8f5959 commit 91b137e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

py/builtinevex.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,18 @@ STATIC mp_obj_t eval_exec_helper(size_t n_args, const mp_obj_t *args, mp_parse_i
132132
}
133133
#endif
134134

135-
size_t str_len;
136-
const char *str = mp_obj_str_get_data(args[0], &str_len);
135+
// Extract the source code.
136+
mp_buffer_info_t bufinfo;
137+
mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ);
137138

138139
// create the lexer
139140
// MP_PARSE_SINGLE_INPUT is used to indicate a file input
140141
mp_lexer_t *lex;
141142
if (MICROPY_PY_BUILTINS_EXECFILE && parse_input_kind == MP_PARSE_SINGLE_INPUT) {
142-
lex = mp_lexer_new_from_file(str);
143+
lex = mp_lexer_new_from_file(bufinfo.buf);
143144
parse_input_kind = MP_PARSE_FILE_INPUT;
144145
} else {
145-
lex = mp_lexer_new_from_str_len(MP_QSTR__lt_string_gt_, str, str_len, 0);
146+
lex = mp_lexer_new_from_str_len(MP_QSTR__lt_string_gt_, bufinfo.buf, bufinfo.len, 0);
146147
}
147148

148149
return mp_parse_compile_execute(lex, parse_input_kind, globals, locals);

0 commit comments

Comments
 (0)
0