@@ -7,7 +7,7 @@ use std::path::PathBuf;
77
88use super :: builtins;
99use super :: bytecode;
10- use super :: import:: import;
10+ use super :: import:: { import, import_module } ;
1111use super :: obj:: objbool;
1212use super :: obj:: objcode;
1313use super :: obj:: objdict;
@@ -182,6 +182,7 @@ impl Frame {
182182 ref name,
183183 ref symbol,
184184 } => self . import ( vm, name, symbol) ,
185+ bytecode:: Instruction :: ImportStar { ref name } => self . import_star ( vm, name) ,
185186 bytecode:: Instruction :: LoadName { ref name } => self . load_name ( vm, name) ,
186187 bytecode:: Instruction :: StoreName { ref name } => self . store_name ( vm, name) ,
187188 bytecode:: Instruction :: DeleteName { ref name } => self . delete_name ( vm, name) ,
@@ -677,6 +678,26 @@ impl Frame {
677678 Ok ( None )
678679 }
679680
681+ fn import_star ( & mut self , vm : & mut VirtualMachine , module : & str ) -> FrameResult {
682+ let current_path = match & self . code . source_path {
683+ Some ( source_path) => {
684+ let mut source_pathbuf = PathBuf :: from ( source_path) ;
685+ source_pathbuf. pop ( ) ;
686+ source_pathbuf
687+ }
688+ None => PathBuf :: from ( "." ) ,
689+ } ;
690+
691+ // Grab all the names from the module and put them in the context
692+ let obj = import_module ( vm, current_path, module) ?;
693+
694+ for ( k, v) in obj. get_key_value_pairs ( ) . iter ( ) {
695+ vm. ctx
696+ . set_item ( & self . locals , & objstr:: get_value ( k) , v. clone ( ) ) ;
697+ }
698+ Ok ( None )
699+ }
700+
680701 // Unwind all blocks:
681702 fn unwind_blocks ( & mut self , vm : & mut VirtualMachine ) -> Option < PyObjectRef > {
682703 loop {
0 commit comments