@@ -7,7 +7,7 @@ use std::path::PathBuf;
7
7
8
8
use super :: builtins;
9
9
use super :: bytecode;
10
- use super :: import:: import;
10
+ use super :: import:: { import, import_module } ;
11
11
use super :: obj:: objbool;
12
12
use super :: obj:: objcode;
13
13
use super :: obj:: objdict;
@@ -182,6 +182,7 @@ impl Frame {
182
182
ref name,
183
183
ref symbol,
184
184
} => self . import ( vm, name, symbol) ,
185
+ bytecode:: Instruction :: ImportStar { ref name } => self . import_star ( vm, name) ,
185
186
bytecode:: Instruction :: LoadName { ref name } => self . load_name ( vm, name) ,
186
187
bytecode:: Instruction :: StoreName { ref name } => self . store_name ( vm, name) ,
187
188
bytecode:: Instruction :: DeleteName { ref name } => self . delete_name ( vm, name) ,
@@ -677,6 +678,26 @@ impl Frame {
677
678
Ok ( None )
678
679
}
679
680
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
+
680
701
// Unwind all blocks:
681
702
fn unwind_blocks ( & mut self , vm : & mut VirtualMachine ) -> Option < PyObjectRef > {
682
703
loop {
0 commit comments