@@ -3,40 +3,40 @@ use core::fmt;
33use num_bigint:: BigInt ;
44
55use pyo3:: exceptions:: PyKeyError ;
6+ use pyo3:: intern;
67use pyo3:: prelude:: * ;
78use pyo3:: types:: { PyDict , PyString } ;
8- use pyo3:: { intern, FromPyObject } ;
99
1010use crate :: input:: Int ;
1111use jiter:: { cached_py_string, StringCacheMode } ;
1212
1313pub trait SchemaDict < ' py > {
1414 fn get_as < T > ( & self , key : & Bound < ' py , PyString > ) -> PyResult < Option < T > >
1515 where
16- T : FromPyObject < ' py > ;
16+ T : FromPyObjectOwned < ' py > ;
1717
1818 fn get_as_req < T > ( & self , key : & Bound < ' py , PyString > ) -> PyResult < T >
1919 where
20- T : FromPyObject < ' py > ;
20+ T : FromPyObjectOwned < ' py > ;
2121}
2222
2323impl < ' py > SchemaDict < ' py > for Bound < ' py , PyDict > {
2424 fn get_as < T > ( & self , key : & Bound < ' py , PyString > ) -> PyResult < Option < T > >
2525 where
26- T : FromPyObject < ' py > ,
26+ T : FromPyObjectOwned < ' py > ,
2727 {
2828 match self . get_item ( key) ? {
29- Some ( t) => t. extract ( ) . map ( Some ) ,
29+ Some ( t) => t. extract ( ) . map_err ( Into :: into ) . map ( Some ) ,
3030 None => Ok ( None ) ,
3131 }
3232 }
3333
3434 fn get_as_req < T > ( & self , key : & Bound < ' py , PyString > ) -> PyResult < T >
3535 where
36- T : FromPyObject < ' py > ,
36+ T : FromPyObjectOwned < ' py > ,
3737 {
3838 match self . get_item ( key) ? {
39- Some ( t) => t. extract ( ) ,
39+ Some ( t) => t. extract ( ) . map_err ( Into :: into ) ,
4040 None => py_err ! ( PyKeyError ; "{}" , key) ,
4141 }
4242 }
@@ -45,7 +45,7 @@ impl<'py> SchemaDict<'py> for Bound<'py, PyDict> {
4545impl < ' py > SchemaDict < ' py > for Option < & Bound < ' py , PyDict > > {
4646 fn get_as < T > ( & self , key : & Bound < ' py , PyString > ) -> PyResult < Option < T > >
4747 where
48- T : FromPyObject < ' py > ,
48+ T : FromPyObjectOwned < ' py > ,
4949 {
5050 match self {
5151 Some ( d) => d. get_as ( key) ,
@@ -56,7 +56,7 @@ impl<'py> SchemaDict<'py> for Option<&Bound<'py, PyDict>> {
5656 #[ cfg_attr( has_coverage_attribute, coverage( off) ) ]
5757 fn get_as_req < T > ( & self , key : & Bound < ' py , PyString > ) -> PyResult < T >
5858 where
59- T : FromPyObject < ' py > ,
59+ T : FromPyObjectOwned < ' py > ,
6060 {
6161 match self {
6262 Some ( d) => d. get_as_req ( key) ,
0 commit comments