File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -804,7 +804,8 @@ impl VirtualMachine {
804
804
self . new_exception_empty ( stop_iteration_type)
805
805
}
806
806
807
- // TODO: #[track_caller] when stabilized
807
+ #[ track_caller]
808
+ #[ cold]
808
809
fn _py_panic_failed ( & self , exc : PyBaseExceptionRef , msg : & str ) -> ! {
809
810
#[ cfg( not( all( target_arch = "wasm32" , not( target_os = "wasi" ) ) ) ) ]
810
811
{
@@ -831,13 +832,21 @@ impl VirtualMachine {
831
832
panic ! ( "{}; exception backtrace above" , msg)
832
833
}
833
834
}
835
+ #[ track_caller]
834
836
pub fn unwrap_pyresult < T > ( & self , result : PyResult < T > ) -> T {
835
- result. unwrap_or_else ( |exc| {
836
- self . _py_panic_failed ( exc, "called `vm.unwrap_pyresult()` on an `Err` value" )
837
- } )
837
+ match result {
838
+ Ok ( x) => x,
839
+ Err ( exc) => {
840
+ self . _py_panic_failed ( exc, "called `vm.unwrap_pyresult()` on an `Err` value" )
841
+ }
842
+ }
838
843
}
844
+ #[ track_caller]
839
845
pub fn expect_pyresult < T > ( & self , result : PyResult < T > , msg : & str ) -> T {
840
- result. unwrap_or_else ( |exc| self . _py_panic_failed ( exc, msg) )
846
+ match result {
847
+ Ok ( x) => x,
848
+ Err ( exc) => self . _py_panic_failed ( exc, msg) ,
849
+ }
841
850
}
842
851
843
852
pub fn new_scope_with_builtins ( & self ) -> Scope {
You can’t perform that action at this time.
0 commit comments