File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change 1
1
use std:: fmt;
2
2
use std:: sync:: Mutex ;
3
3
4
- use pyo3:: exceptions:: { PyTypeError , PyValueError } ;
5
- use pyo3:: intern;
4
+ use pyo3:: exceptions:: { PyTypeError , PyUserWarning , PyValueError } ;
6
5
use pyo3:: prelude:: * ;
7
6
use pyo3:: types:: { PyBool , PyString } ;
7
+ use pyo3:: { intern, PyTypeInfo } ;
8
8
9
9
use serde:: ser:: Error ;
10
10
@@ -471,7 +471,7 @@ impl CollectWarnings {
471
471
472
472
let message = format ! ( "Pydantic serializer warnings:\n {}" , warnings. join( "\n " ) ) ;
473
473
if self . mode == WarningsMode :: Warn {
474
- let user_warning_type = py . import_bound ( "builtins" ) ? . getattr ( "UserWarning" ) ? ;
474
+ let user_warning_type = PyUserWarning :: type_object ( py ) ;
475
475
PyErr :: warn_bound ( py, & user_warning_type, & message, 0 )
476
476
} else {
477
477
Err ( PydanticSerializationError :: new_err ( message) )
You can’t perform that action at this time.
0 commit comments