@@ -3,7 +3,7 @@ use std::fmt::{Display, Write};
3
3
use std:: str:: from_utf8;
4
4
5
5
use pyo3:: exceptions:: { PyKeyError , PyTypeError , PyValueError } ;
6
- use pyo3:: ffi;
6
+ use pyo3:: ffi:: { self , c_str } ;
7
7
use pyo3:: intern;
8
8
use pyo3:: prelude:: * ;
9
9
use pyo3:: sync:: GILOnceCell ;
@@ -73,7 +73,7 @@ impl ValidationError {
73
73
return cause_problem;
74
74
}
75
75
}
76
- PyErr :: from_value_bound ( err. into_bound ( py) . into_any ( ) )
76
+ PyErr :: from_value ( err. into_bound ( py) . into_any ( ) )
77
77
}
78
78
Err ( err) => err,
79
79
}
@@ -145,7 +145,7 @@ impl ValidationError {
145
145
use pyo3:: exceptions:: PyUserWarning ;
146
146
147
147
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) ) ) ) ;
149
149
user_py_errs. push ( wrapped) ;
150
150
}
151
151
}
@@ -167,7 +167,7 @@ impl ValidationError {
167
167
#[ cfg( not( Py_3_11 ) ) ]
168
168
let cause = {
169
169
use pyo3:: exceptions:: PyImportError ;
170
- match py. import_bound ( "exceptiongroup" ) {
170
+ match py. import ( "exceptiongroup" ) {
171
171
Ok ( py_mod) => match py_mod. getattr ( "ExceptionGroup" ) {
172
172
Ok ( group_cls) => match group_cls. call1 ( ( title, user_py_errs) ) {
173
173
Ok ( group_instance) => Some ( group_instance. into_py ( py) ) ,
@@ -202,10 +202,10 @@ fn include_url_env(py: Python) -> bool {
202
202
match std:: env:: var_os ( "PYDANTIC_ERRORS_OMIT_URL" ) {
203
203
Some ( val) => {
204
204
// We don't care whether warning succeeded or not, hence the assignment
205
- let _ = PyErr :: warn_bound (
205
+ let _ = PyErr :: warn (
206
206
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" ) ,
209
209
1 ,
210
210
) ;
211
211
// If OMIT_URL exists but is empty, we include the URL:
@@ -298,7 +298,7 @@ impl ValidationError {
298
298
) -> PyResult < Py < PyList > > {
299
299
let url_prefix = get_url_prefix ( py, include_url) ;
300
300
let mut iteration_error = None ;
301
- let list = PyList :: new_bound (
301
+ let list = PyList :: new (
302
302
py,
303
303
// PyList::new takes ExactSizeIterator, so if an error occurs during iteration we
304
304
// fill the list with None before returning the error; the list will then be thrown
@@ -313,7 +313,7 @@ impl ValidationError {
313
313
py. None ( )
314
314
} )
315
315
} ) ,
316
- ) ;
316
+ ) ? ;
317
317
if let Some ( err) = iteration_error {
318
318
Err ( err)
319
319
} else {
@@ -368,7 +368,7 @@ impl ValidationError {
368
368
}
369
369
} ;
370
370
let s = from_utf8 ( & bytes) . map_err ( json_py_err) ?;
371
- Ok ( PyString :: new_bound ( py, s) )
371
+ Ok ( PyString :: new ( py, s) )
372
372
}
373
373
374
374
fn __repr__ ( & self , py : Python ) -> String {
@@ -489,7 +489,7 @@ impl PyLineError {
489
489
input_type : InputType ,
490
490
include_input : bool ,
491
491
) -> PyResult < PyObject > {
492
- let dict = PyDict :: new_bound ( py) ;
492
+ let dict = PyDict :: new ( py) ;
493
493
dict. set_item ( "type" , self . error_type . type_string ( ) ) ?;
494
494
dict. set_item ( "loc" , self . location . to_object ( py) ) ?;
495
495
dict. set_item ( "msg" , self . error_type . render_message ( py, input_type) ?) ?;
0 commit comments