We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ab0e4bd commit be87e05Copy full SHA for be87e05
src/serializers/extra.rs
@@ -1,10 +1,10 @@
1
use std::fmt;
2
use std::sync::Mutex;
3
4
-use pyo3::exceptions::{PyTypeError, PyValueError};
5
-use pyo3::intern;
+use pyo3::exceptions::{PyTypeError, PyUserWarning, PyValueError};
6
use pyo3::prelude::*;
7
use pyo3::types::{PyBool, PyString};
+use pyo3::{intern, PyTypeInfo};
8
9
use serde::ser::Error;
10
@@ -471,7 +471,7 @@ impl CollectWarnings {
471
472
let message = format!("Pydantic serializer warnings:\n {}", warnings.join("\n "));
473
if self.mode == WarningsMode::Warn {
474
- let user_warning_type = py.import_bound("builtins")?.getattr("UserWarning")?;
+ let user_warning_type = PyUserWarning::type_object(py);
475
PyErr::warn_bound(py, &user_warning_type, &message, 0)
476
} else {
477
Err(PydanticSerializationError::new_err(message))
0 commit comments