summaryrefslogtreecommitdiffstatshomepage
path: root/py/compile.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-04-27 19:23:46 +0100
committerDamien George <damien.p.george@gmail.com>2014-04-27 19:23:46 +0100
commit708c07325007148d8e553b20df3f9110cedb58ab (patch)
tree0ecae18e4c406d3d9ffb4c1195ee1400ac4ffd67 /py/compile.c
parent968bf34c4c7c457816eb3a9d8358519ba1d3a65f (diff)
downloadmicropython-708c07325007148d8e553b20df3f9110cedb58ab.tar.gz
micropython-708c07325007148d8e553b20df3f9110cedb58ab.zip
py: Add '*' qstr for 'import *'; use blank qstr for comprehension arg.
Diffstat (limited to 'py/compile.c')
-rw-r--r--py/compile.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/py/compile.c b/py/compile.c
index 8d934d5e56..2686d2d311 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -1416,7 +1416,7 @@ void compile_import_from(compiler_t *comp, mp_parse_node_struct_t *pns) {
#if MICROPY_EMIT_CPYTHON
EMIT_ARG(load_const_verbatim_str, "('*',)");
#else
- EMIT_ARG(load_const_str, QSTR_FROM_STR_STATIC("*"), false);
+ EMIT_ARG(load_const_str, MP_QSTR__star_, false);
EMIT_ARG(build_tuple, 1);
#endif
@@ -3040,7 +3040,15 @@ STATIC void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_comp_for));
mp_parse_node_struct_t *pns_comp_for = (mp_parse_node_struct_t*)pns->nodes[1];
+ // We need a unique name for the comprehension argument (the iterator).
+ // CPython uses .0, but we should be able to use anything that won't
+ // clash with a user defined variable. Best to use an existing qstr,
+ // so we use the blank qstr.
+#if MICROPY_EMIT_CPYTHON
qstr qstr_arg = QSTR_FROM_STR_STATIC(".0");
+#else
+ qstr qstr_arg = MP_QSTR_;
+#endif
if (comp->pass == PASS_1) {
bool added;
id_info_t *id_info = scope_find_or_add_id(comp->scope_cur, qstr_arg, &added);