File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -739,8 +739,8 @@ impl Frame {
739739 } ;
740740 let context = match argc {
741741 0 => vm. get_none ( ) , // We have already got the exception,
742- _ => match vm. pop_exception ( ) {
743- Some ( exc) => exc,
742+ _ => match vm. last_exception ( ) {
743+ Some ( exc) => exc. clone ( ) ,
744744 None => vm. get_none ( ) ,
745745 } ,
746746 } ;
Original file line number Diff line number Diff line change @@ -931,6 +931,17 @@ impl VirtualMachine {
931931 pub fn pop_exception ( & self ) -> Option < PyObjectRef > {
932932 self . exceptions . borrow_mut ( ) . pop ( )
933933 }
934+
935+ pub fn last_exception ( & self ) -> Option < Ref < PyObjectRef > > {
936+ let exceptions = self . exceptions . borrow ( ) ;
937+ if exceptions. is_empty ( ) {
938+ None
939+ } else {
940+ Some ( Ref :: map ( self . exceptions . borrow ( ) , |exceptions| {
941+ exceptions. last ( ) . unwrap ( )
942+ } ) )
943+ }
944+ }
934945}
935946
936947impl Default for VirtualMachine {
You can’t perform that action at this time.
0 commit comments