File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed
serializers/type_serializers Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -244,16 +244,16 @@ impl<'a> Input<'a> for PyAny {
244
244
}
245
245
246
246
fn strict_bool ( & self ) -> ValResult < bool > {
247
- if let Ok ( bool) = self . extract :: < bool > ( ) {
248
- Ok ( bool)
247
+ if let Ok ( bool) = self . downcast :: < PyBool > ( ) {
248
+ Ok ( bool. is_true ( ) )
249
249
} else {
250
250
Err ( ValError :: new ( ErrorType :: BoolType , self ) )
251
251
}
252
252
}
253
253
254
254
fn lax_bool ( & self ) -> ValResult < bool > {
255
- if let Ok ( bool) = self . extract :: < bool > ( ) {
256
- Ok ( bool)
255
+ if let Ok ( bool) = self . downcast :: < PyBool > ( ) {
256
+ Ok ( bool. is_true ( ) )
257
257
} else if let Some ( cow_str) = maybe_as_string ( self , ErrorType :: BoolParsing ) ? {
258
258
str_as_bool ( self , & cow_str)
259
259
} else if let Ok ( int) = extract_i64 ( self ) {
Original file line number Diff line number Diff line change 1
1
use std:: borrow:: Cow ;
2
2
3
- use pyo3:: intern;
4
3
use pyo3:: prelude:: * ;
5
- use pyo3:: types:: { PyDict , PyList , PyString } ;
4
+ use pyo3:: types:: { PyBool , PyDict , PyList , PyString } ;
5
+ use pyo3:: { intern, PyTypeInfo } ;
6
6
7
7
use ahash:: AHashSet ;
8
8
use serde:: Serialize ;
@@ -76,7 +76,7 @@ enum OutputValue<'a> {
76
76
impl LiteralSerializer {
77
77
fn check < ' a > ( & self , value : & ' a PyAny , extra : & Extra ) -> PyResult < OutputValue < ' a > > {
78
78
if extra. check . enabled ( ) {
79
- if !self . expected_int . is_empty ( ) && value . extract :: < bool > ( ) . is_err ( ) {
79
+ if !self . expected_int . is_empty ( ) && ! PyBool :: is_type_of ( value ) {
80
80
if let Ok ( int) = extract_i64 ( value) {
81
81
if self . expected_int . contains ( & int) {
82
82
return Ok ( OutputValue :: OkInt ( int) ) ;
You can’t perform that action at this time.
0 commit comments