@@ -466,33 +466,30 @@ pub fn uninstall_tracer(py: Python<'_>) -> PyResult<()> {
466466#[ pyfunction]
467467fn callback_call (
468468 py : Python < ' _ > ,
469- code : Bound < ' _ , PyAny > ,
469+ code : Bound < ' _ , PyCode > ,
470470 offset : i32 ,
471471 callable : Bound < ' _ , PyAny > ,
472472 arg0 : Option < Bound < ' _ , PyAny > > ,
473473) -> PyResult < ( ) > {
474474 if let Some ( global) = GLOBAL . lock ( ) . unwrap ( ) . as_mut ( ) {
475- let code = code. downcast :: < PyCode > ( ) ?;
476475 let wrapper = CodeObjectWrapper :: new ( py, & code) ;
477476 global. tracer . on_call ( py, & wrapper, offset, & callable, arg0. as_ref ( ) ) ;
478477 }
479478 Ok ( ( ) )
480479}
481480
482481#[ pyfunction]
483- fn callback_line ( py : Python < ' _ > , code : Bound < ' _ , PyAny > , lineno : u32 ) -> PyResult < ( ) > {
482+ fn callback_line ( py : Python < ' _ > , code : Bound < ' _ , PyCode > , lineno : u32 ) -> PyResult < ( ) > {
484483 if let Some ( global) = GLOBAL . lock ( ) . unwrap ( ) . as_mut ( ) {
485- let code = code. downcast :: < PyCode > ( ) ?;
486484 let wrapper = CodeObjectWrapper :: new ( py, & code) ;
487485 global. tracer . on_line ( py, & wrapper, lineno) ;
488486 }
489487 Ok ( ( ) )
490488}
491489
492490#[ pyfunction]
493- fn callback_instruction ( py : Python < ' _ > , code : Bound < ' _ , PyAny > , instruction_offset : i32 ) -> PyResult < ( ) > {
491+ fn callback_instruction ( py : Python < ' _ > , code : Bound < ' _ , PyCode > , instruction_offset : i32 ) -> PyResult < ( ) > {
494492 if let Some ( global) = GLOBAL . lock ( ) . unwrap ( ) . as_mut ( ) {
495- let code = code. downcast :: < PyCode > ( ) ?;
496493 let wrapper = CodeObjectWrapper :: new ( py, & code) ;
497494 global. tracer . on_instruction ( py, & wrapper, instruction_offset) ;
498495 }
@@ -502,12 +499,11 @@ fn callback_instruction(py: Python<'_>, code: Bound<'_, PyAny>, instruction_offs
502499#[ pyfunction]
503500fn callback_jump (
504501 py : Python < ' _ > ,
505- code : Bound < ' _ , PyAny > ,
502+ code : Bound < ' _ , PyCode > ,
506503 instruction_offset : i32 ,
507504 destination_offset : i32 ,
508505) -> PyResult < ( ) > {
509506 if let Some ( global) = GLOBAL . lock ( ) . unwrap ( ) . as_mut ( ) {
510- let code = code. downcast :: < PyCode > ( ) ?;
511507 let wrapper = CodeObjectWrapper :: new ( py, & code) ;
512508 global
513509 . tracer
@@ -519,12 +515,11 @@ fn callback_jump(
519515#[ pyfunction]
520516fn callback_branch (
521517 py : Python < ' _ > ,
522- code : Bound < ' _ , PyAny > ,
518+ code : Bound < ' _ , PyCode > ,
523519 instruction_offset : i32 ,
524520 destination_offset : i32 ,
525521) -> PyResult < ( ) > {
526522 if let Some ( global) = GLOBAL . lock ( ) . unwrap ( ) . as_mut ( ) {
527- let code = code. downcast :: < PyCode > ( ) ?;
528523 let wrapper = CodeObjectWrapper :: new ( py, & code) ;
529524 global
530525 . tracer
@@ -534,19 +529,17 @@ fn callback_branch(
534529}
535530
536531#[ pyfunction]
537- fn callback_py_start ( py : Python < ' _ > , code : Bound < ' _ , PyAny > , instruction_offset : i32 ) -> PyResult < ( ) > {
532+ fn callback_py_start ( py : Python < ' _ > , code : Bound < ' _ , PyCode > , instruction_offset : i32 ) -> PyResult < ( ) > {
538533 if let Some ( global) = GLOBAL . lock ( ) . unwrap ( ) . as_mut ( ) {
539- let code = code. downcast :: < PyCode > ( ) ?;
540534 let wrapper = CodeObjectWrapper :: new ( py, & code) ;
541535 global. tracer . on_py_start ( py, & wrapper, instruction_offset) ;
542536 }
543537 Ok ( ( ) )
544538}
545539
546540#[ pyfunction]
547- fn callback_py_resume ( py : Python < ' _ > , code : Bound < ' _ , PyAny > , instruction_offset : i32 ) -> PyResult < ( ) > {
541+ fn callback_py_resume ( py : Python < ' _ > , code : Bound < ' _ , PyCode > , instruction_offset : i32 ) -> PyResult < ( ) > {
548542 if let Some ( global) = GLOBAL . lock ( ) . unwrap ( ) . as_mut ( ) {
549- let code = code. downcast :: < PyCode > ( ) ?;
550543 let wrapper = CodeObjectWrapper :: new ( py, & code) ;
551544 global. tracer . on_py_resume ( py, & wrapper, instruction_offset) ;
552545 }
@@ -556,12 +549,11 @@ fn callback_py_resume(py: Python<'_>, code: Bound<'_, PyAny>, instruction_offset
556549#[ pyfunction]
557550fn callback_py_return (
558551 py : Python < ' _ > ,
559- code : Bound < ' _ , PyAny > ,
552+ code : Bound < ' _ , PyCode > ,
560553 instruction_offset : i32 ,
561554 retval : Bound < ' _ , PyAny > ,
562555) -> PyResult < ( ) > {
563556 if let Some ( global) = GLOBAL . lock ( ) . unwrap ( ) . as_mut ( ) {
564- let code = code. downcast :: < PyCode > ( ) ?;
565557 let wrapper = CodeObjectWrapper :: new ( py, & code) ;
566558 global. tracer . on_py_return ( py, & wrapper, instruction_offset, & retval) ;
567559 }
@@ -571,12 +563,11 @@ fn callback_py_return(
571563#[ pyfunction]
572564fn callback_py_yield (
573565 py : Python < ' _ > ,
574- code : Bound < ' _ , PyAny > ,
566+ code : Bound < ' _ , PyCode > ,
575567 instruction_offset : i32 ,
576568 retval : Bound < ' _ , PyAny > ,
577569) -> PyResult < ( ) > {
578570 if let Some ( global) = GLOBAL . lock ( ) . unwrap ( ) . as_mut ( ) {
579- let code = code. downcast :: < PyCode > ( ) ?;
580571 let wrapper = CodeObjectWrapper :: new ( py, & code) ;
581572 global. tracer . on_py_yield ( py, & wrapper, instruction_offset, & retval) ;
582573 }
@@ -586,12 +577,11 @@ fn callback_py_yield(
586577#[ pyfunction]
587578fn callback_py_throw (
588579 py : Python < ' _ > ,
589- code : Bound < ' _ , PyAny > ,
580+ code : Bound < ' _ , PyCode > ,
590581 instruction_offset : i32 ,
591582 exception : Bound < ' _ , PyAny > ,
592583) -> PyResult < ( ) > {
593584 if let Some ( global) = GLOBAL . lock ( ) . unwrap ( ) . as_mut ( ) {
594- let code = code. downcast :: < PyCode > ( ) ?;
595585 let wrapper = CodeObjectWrapper :: new ( py, & code) ;
596586 global. tracer . on_py_throw ( py, & wrapper, instruction_offset, & exception) ;
597587 }
@@ -601,12 +591,11 @@ fn callback_py_throw(
601591#[ pyfunction]
602592fn callback_py_unwind (
603593 py : Python < ' _ > ,
604- code : Bound < ' _ , PyAny > ,
594+ code : Bound < ' _ , PyCode > ,
605595 instruction_offset : i32 ,
606596 exception : Bound < ' _ , PyAny > ,
607597) -> PyResult < ( ) > {
608598 if let Some ( global) = GLOBAL . lock ( ) . unwrap ( ) . as_mut ( ) {
609- let code = code. downcast :: < PyCode > ( ) ?;
610599 let wrapper = CodeObjectWrapper :: new ( py, & code) ;
611600 global. tracer . on_py_unwind ( py, & wrapper, instruction_offset, & exception) ;
612601 }
@@ -616,12 +605,11 @@ fn callback_py_unwind(
616605#[ pyfunction]
617606fn callback_raise (
618607 py : Python < ' _ > ,
619- code : Bound < ' _ , PyAny > ,
608+ code : Bound < ' _ , PyCode > ,
620609 instruction_offset : i32 ,
621610 exception : Bound < ' _ , PyAny > ,
622611) -> PyResult < ( ) > {
623612 if let Some ( global) = GLOBAL . lock ( ) . unwrap ( ) . as_mut ( ) {
624- let code = code. downcast :: < PyCode > ( ) ?;
625613 let wrapper = CodeObjectWrapper :: new ( py, & code) ;
626614 global. tracer . on_raise ( py, & wrapper, instruction_offset, & exception) ;
627615 }
@@ -631,12 +619,11 @@ fn callback_raise(
631619#[ pyfunction]
632620fn callback_reraise (
633621 py : Python < ' _ > ,
634- code : Bound < ' _ , PyAny > ,
622+ code : Bound < ' _ , PyCode > ,
635623 instruction_offset : i32 ,
636624 exception : Bound < ' _ , PyAny > ,
637625) -> PyResult < ( ) > {
638626 if let Some ( global) = GLOBAL . lock ( ) . unwrap ( ) . as_mut ( ) {
639- let code = code. downcast :: < PyCode > ( ) ?;
640627 let wrapper = CodeObjectWrapper :: new ( py, & code) ;
641628 global. tracer . on_reraise ( py, & wrapper, instruction_offset, & exception) ;
642629 }
@@ -646,12 +633,11 @@ fn callback_reraise(
646633#[ pyfunction]
647634fn callback_exception_handled (
648635 py : Python < ' _ > ,
649- code : Bound < ' _ , PyAny > ,
636+ code : Bound < ' _ , PyCode > ,
650637 instruction_offset : i32 ,
651638 exception : Bound < ' _ , PyAny > ,
652639) -> PyResult < ( ) > {
653640 if let Some ( global) = GLOBAL . lock ( ) . unwrap ( ) . as_mut ( ) {
654- let code = code. downcast :: < PyCode > ( ) ?;
655641 let wrapper = CodeObjectWrapper :: new ( py, & code) ;
656642 global
657643 . tracer
@@ -679,13 +665,12 @@ fn callback_exception_handled(
679665#[ pyfunction]
680666fn callback_c_return (
681667 py : Python < ' _ > ,
682- code : Bound < ' _ , PyAny > ,
668+ code : Bound < ' _ , PyCode > ,
683669 offset : i32 ,
684670 callable : Bound < ' _ , PyAny > ,
685671 arg0 : Option < Bound < ' _ , PyAny > > ,
686672) -> PyResult < ( ) > {
687673 if let Some ( global) = GLOBAL . lock ( ) . unwrap ( ) . as_mut ( ) {
688- let code = code. downcast :: < PyCode > ( ) ?;
689674 let wrapper = CodeObjectWrapper :: new ( py, & code) ;
690675 global
691676 . tracer
@@ -697,13 +682,12 @@ fn callback_c_return(
697682#[ pyfunction]
698683fn callback_c_raise (
699684 py : Python < ' _ > ,
700- code : Bound < ' _ , PyAny > ,
685+ code : Bound < ' _ , PyCode > ,
701686 offset : i32 ,
702687 callable : Bound < ' _ , PyAny > ,
703688 arg0 : Option < Bound < ' _ , PyAny > > ,
704689) -> PyResult < ( ) > {
705690 if let Some ( global) = GLOBAL . lock ( ) . unwrap ( ) . as_mut ( ) {
706- let code = code. downcast :: < PyCode > ( ) ?;
707691 let wrapper = CodeObjectWrapper :: new ( py, & code) ;
708692 global
709693 . tracer
0 commit comments