@@ -179,10 +179,7 @@ impl VirtualMachine {
179
179
// Assume top of stack is __exit__ method:
180
180
// TODO: do we want to put the exit call on the stack?
181
181
let exit_method = self . pop_value ( ) ;
182
- let args = PyFuncArgs {
183
- args : vec ! [ ] ,
184
- kwargs : vec ! [ ] ,
185
- } ;
182
+ let args = PyFuncArgs :: default ( ) ;
186
183
// TODO: what happens when we got an error during handling exception?
187
184
self . invoke ( exit_method, args) . unwrap ( ) ;
188
185
}
@@ -842,15 +839,15 @@ impl VirtualMachine {
842
839
None
843
840
}
844
841
bytecode:: Instruction :: SetupWith { end } => {
845
- let obj = self . pop_value ( ) ;
842
+ let context_manager = self . pop_value ( ) ;
846
843
// Call enter:
847
- match self . call_method ( obj , "__enter__" , vec ! [ ] ) {
848
- Ok ( manager ) => {
844
+ match self . call_method ( context_manager . clone ( ) , "__enter__" , vec ! [ ] ) {
845
+ Ok ( obj ) => {
849
846
self . push_block ( Block :: With {
850
847
end : * end,
851
- context_manager : manager . clone ( ) ,
848
+ context_manager : context_manager . clone ( ) ,
852
849
} ) ;
853
- self . push_value ( manager ) ;
850
+ self . push_value ( obj ) ;
854
851
None
855
852
}
856
853
Err ( err) => Some ( Err ( err) ) ,
@@ -866,6 +863,7 @@ impl VirtualMachine {
866
863
assert ! ( end1 == end2) ;
867
864
868
865
// call exit now:
866
+ // TODO: improve exception handling in context manager.
869
867
let exc_type = self . ctx . none ( ) ;
870
868
let exc_val = self . ctx . none ( ) ;
871
869
let exc_tb = self . ctx . none ( ) ;
0 commit comments