Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
21c719bd
Commit
21c719bd
authored
Aug 22, 2016
by
Delio Brignoli
Committed by
Paul Sokolovsky
Sep 20, 2016
Browse files
builtinimport: add the module specified by -m to sys.modules as '__main__'
parent
34e01984
Changes
1
Hide whitespace changes
Inline
Side-by-side
py/builtinimport.c
View file @
21c719bd
...
...
@@ -448,6 +448,8 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
mp_obj_module_t
*
o
=
MP_OBJ_TO_PTR
(
module_obj
);
mp_obj_dict_store
(
MP_OBJ_FROM_PTR
(
o
->
globals
),
MP_OBJ_NEW_QSTR
(
MP_QSTR___name__
),
MP_OBJ_NEW_QSTR
(
MP_QSTR___main__
));
#if MICROPY_CPYTHON_COMPAT
// Store module as "__main__" in the dictionary of loaded modules (returned by sys.modules).
mp_obj_dict_store
(
&
MP_STATE_VM
(
mp_loaded_modules_dict
),
MP_OBJ_NEW_QSTR
(
MP_QSTR___main__
),
module_obj
);
// Store real name in "__main__" attribute. Choosen semi-randonly, to reuse existing qstr's.
mp_obj_dict_store
(
MP_OBJ_FROM_PTR
(
o
->
globals
),
MP_OBJ_NEW_QSTR
(
MP_QSTR___main__
),
MP_OBJ_NEW_QSTR
(
mod_name
));
#endif
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment