@@ -3,7 +3,7 @@ use std::fmt::{Display, Write};
33use std:: str:: from_utf8;
44
55use pyo3:: exceptions:: { PyKeyError , PyTypeError , PyValueError } ;
6- use pyo3:: ffi;
6+ use pyo3:: ffi:: { self , c_str } ;
77use pyo3:: intern;
88use pyo3:: prelude:: * ;
99use pyo3:: sync:: GILOnceCell ;
@@ -73,7 +73,7 @@ impl ValidationError {
7373 return cause_problem;
7474 }
7575 }
76- PyErr :: from_value_bound ( err. into_bound ( py) . into_any ( ) )
76+ PyErr :: from_value ( err. into_bound ( py) . into_any ( ) )
7777 }
7878 Err ( err) => err,
7979 }
@@ -145,7 +145,7 @@ impl ValidationError {
145145 use pyo3:: exceptions:: PyUserWarning ;
146146
147147 let wrapped = PyUserWarning :: new_err ( ( note, ) ) ;
148- wrapped. set_cause ( py, Some ( PyErr :: from_value_bound ( err. clone_ref ( py) . into_bound ( py) ) ) ) ;
148+ wrapped. set_cause ( py, Some ( PyErr :: from_value ( err. clone_ref ( py) . into_bound ( py) ) ) ) ;
149149 user_py_errs. push ( wrapped) ;
150150 }
151151 }
@@ -167,7 +167,7 @@ impl ValidationError {
167167 #[ cfg( not( Py_3_11 ) ) ]
168168 let cause = {
169169 use pyo3:: exceptions:: PyImportError ;
170- match py. import_bound ( "exceptiongroup" ) {
170+ match py. import ( "exceptiongroup" ) {
171171 Ok ( py_mod) => match py_mod. getattr ( "ExceptionGroup" ) {
172172 Ok ( group_cls) => match group_cls. call1 ( ( title, user_py_errs) ) {
173173 Ok ( group_instance) => Some ( group_instance. into_py ( py) ) ,
@@ -202,10 +202,10 @@ fn include_url_env(py: Python) -> bool {
202202 match std:: env:: var_os ( "PYDANTIC_ERRORS_OMIT_URL" ) {
203203 Some ( val) => {
204204 // We don't care whether warning succeeded or not, hence the assignment
205- let _ = PyErr :: warn_bound (
205+ let _ = PyErr :: warn (
206206 py,
207- & py. get_type_bound :: < pyo3:: exceptions:: PyDeprecationWarning > ( ) ,
208- "PYDANTIC_ERRORS_OMIT_URL is deprecated, use PYDANTIC_ERRORS_INCLUDE_URL instead" ,
207+ & py. get_type :: < pyo3:: exceptions:: PyDeprecationWarning > ( ) ,
208+ c_str ! ( "PYDANTIC_ERRORS_OMIT_URL is deprecated, use PYDANTIC_ERRORS_INCLUDE_URL instead" ) ,
209209 1 ,
210210 ) ;
211211 // If OMIT_URL exists but is empty, we include the URL:
@@ -298,7 +298,7 @@ impl ValidationError {
298298 ) -> PyResult < Py < PyList > > {
299299 let url_prefix = get_url_prefix ( py, include_url) ;
300300 let mut iteration_error = None ;
301- let list = PyList :: new_bound (
301+ let list = PyList :: new (
302302 py,
303303 // PyList::new takes ExactSizeIterator, so if an error occurs during iteration we
304304 // fill the list with None before returning the error; the list will then be thrown
@@ -313,7 +313,7 @@ impl ValidationError {
313313 py. None ( )
314314 } )
315315 } ) ,
316- ) ;
316+ ) ? ;
317317 if let Some ( err) = iteration_error {
318318 Err ( err)
319319 } else {
@@ -368,7 +368,7 @@ impl ValidationError {
368368 }
369369 } ;
370370 let s = from_utf8 ( & bytes) . map_err ( json_py_err) ?;
371- Ok ( PyString :: new_bound ( py, s) )
371+ Ok ( PyString :: new ( py, s) )
372372 }
373373
374374 fn __repr__ ( & self , py : Python ) -> String {
@@ -489,7 +489,7 @@ impl PyLineError {
489489 input_type : InputType ,
490490 include_input : bool ,
491491 ) -> PyResult < PyObject > {
492- let dict = PyDict :: new_bound ( py) ;
492+ let dict = PyDict :: new ( py) ;
493493 dict. set_item ( "type" , self . error_type . type_string ( ) ) ?;
494494 dict. set_item ( "loc" , self . location . to_object ( py) ) ?;
495495 dict. set_item ( "msg" , self . error_type . render_message ( py, input_type) ?) ?;
0 commit comments