@@ -79,39 +79,33 @@ impl ValidationErrorIter {
7979}
8080
8181fn into_py_err ( py : Python < ' _ > , error : jsonschema:: ValidationError < ' _ > ) -> PyResult < PyErr > {
82- let pyerror_type = PyType :: new_bound :: < ValidationError > ( py) ;
82+ let pyerror_type = PyType :: new :: < ValidationError > ( py) ;
8383 let message = error. to_string ( ) ;
8484 let verbose_message = to_error_message ( & error, message. clone ( ) ) ;
8585 let into_path = |segment : & str | {
8686 if let Ok ( idx) = segment. parse :: < usize > ( ) {
87- idx. into_py ( py)
87+ idx. into_pyobject ( py) . and_then ( PyObject :: try_from )
8888 } else {
89- segment. into_py ( py)
89+ segment. into_pyobject ( py) . and_then ( PyObject :: try_from )
9090 }
9191 } ;
92- let schema_path = PyList :: new_bound (
93- py,
94- error
95- . schema_path
96- . as_str ( )
97- . split ( '/' )
98- . skip ( 1 )
99- . map ( into_path)
100- . collect :: < Vec < _ > > ( ) ,
101- )
102- . unbind ( ) ;
103- let instance_path = PyList :: new_bound (
104- py,
105- error
106- . instance_path
107- . as_str ( )
108- . split ( '/' )
109- . skip ( 1 )
110- . map ( into_path)
111- . collect :: < Vec < _ > > ( ) ,
112- )
113- . unbind ( ) ;
114- Ok ( PyErr :: from_type_bound (
92+ let elements = error
93+ . schema_path
94+ . as_str ( )
95+ . split ( '/' )
96+ . skip ( 1 )
97+ . map ( into_path)
98+ . collect :: < Result < Vec < _ > , _ > > ( ) ?;
99+ let schema_path = PyList :: new ( py, elements) ?. unbind ( ) ;
100+ let elements = error
101+ . instance_path
102+ . as_str ( )
103+ . split ( '/' )
104+ . skip ( 1 )
105+ . map ( into_path)
106+ . collect :: < Result < Vec < _ > , _ > > ( ) ?;
107+ let instance_path = PyList :: new ( py, elements) ?. unbind ( ) ;
108+ Ok ( PyErr :: from_type (
115109 pyerror_type,
116110 ( message, verbose_message, schema_path, instance_path) ,
117111 ) )
@@ -161,8 +155,8 @@ fn make_options(
161155 let callback: Py < PyAny > = callback. clone ( ) . unbind ( ) ;
162156 let call_py_callback = move |value : & str | {
163157 Python :: with_gil ( |py| {
164- let value = PyString :: new_bound ( py, value) ;
165- callback. call_bound ( py, ( value, ) , None ) ?. is_truthy ( py)
158+ let value = PyString :: new ( py, value) ;
159+ callback. call ( py, ( value, ) , None ) ?. is_truthy ( py)
166160 } )
167161 } ;
168162 options. with_format (
@@ -719,14 +713,15 @@ fn jsonschema_rs(py: Python<'_>, module: &Bound<'_, PyModule>) -> PyResult<()> {
719713 module. add_class :: < Draft7Validator > ( ) ?;
720714 module. add_class :: < Draft201909Validator > ( ) ?;
721715 module. add_class :: < Draft202012Validator > ( ) ?;
722- module. add ( "ValidationError" , py. get_type_bound :: < ValidationError > ( ) ) ?;
716+ module. add ( "ValidationError" , py. get_type :: < ValidationError > ( ) ) ?;
723717 module. add ( "Draft4" , DRAFT4 ) ?;
724718 module. add ( "Draft6" , DRAFT6 ) ?;
725719 module. add ( "Draft7" , DRAFT7 ) ?;
726720 module. add ( "Draft201909" , DRAFT201909 ) ?;
727721 module. add ( "Draft202012" , DRAFT202012 ) ?;
728722
729723 // Add build metadata to ease triaging incoming issues
724+ #[ allow( deprecated) ]
730725 module. add ( "__build__" , pyo3_built:: pyo3_built!( py, build) ) ?;
731726
732727 Ok ( ( ) )
0 commit comments