File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -925,15 +925,15 @@ impl ExecutingFrame<'_> {
925
925
_ => None ,
926
926
} ;
927
927
928
- let exit = self . pop_value ( ) ;
928
+ let exit = self . top_value ( ) ;
929
929
930
930
let args = if let Some ( exc) = exc {
931
931
vm. split_exception ( exc)
932
932
} else {
933
933
( vm. ctx . none ( ) , vm. ctx . none ( ) , vm. ctx . none ( ) )
934
934
} ;
935
935
let exit_res = exit. call ( args, vm) ?;
936
- self . push_value ( exit_res) ;
936
+ self . replace_top ( exit_res) ;
937
937
938
938
Ok ( None )
939
939
}
@@ -1954,6 +1954,13 @@ impl ExecutingFrame<'_> {
1954
1954
self . state . stack . drain ( stack_len - count..)
1955
1955
}
1956
1956
1957
+ #[ inline]
1958
+ fn replace_top ( & mut self , mut top : PyObjectRef ) -> PyObjectRef {
1959
+ let last = self . state . stack . last_mut ( ) . unwrap ( ) ;
1960
+ std:: mem:: swap ( & mut top, last) ;
1961
+ top
1962
+ }
1963
+
1957
1964
#[ inline]
1958
1965
#[ track_caller] // not a real track_caller but top_value is not very useful
1959
1966
fn top_value ( & self ) -> & PyObject {
You can’t perform that action at this time.
0 commit comments