@@ -57,7 +57,7 @@ impl From<PyCanonicalJSONError> for pyo3::PyErr {
57
57
58
58
/// A canonical JSON serializer written in Rust
59
59
#[ pymodule]
60
- fn canonicaljson ( _py : Python , m : & PyModule ) -> PyResult < ( ) > {
60
+ fn canonicaljson ( _py : Python , m : & Bound < ' _ , PyModule > ) -> PyResult < ( ) > {
61
61
m. add ( "__version__" , env ! ( "CARGO_PKG_VERSION" ) ) ?;
62
62
63
63
m. add_wrapped ( wrap_pyfunction ! ( dump) ) ?;
@@ -105,7 +105,7 @@ fn to_json(py: Python, obj: &PyObject) -> Result<serde_json::Value, PyCanonicalJ
105
105
} ;
106
106
}
107
107
108
- if obj. as_ref ( py) . eq ( & py. None ( ) ) ? {
108
+ if obj. bind ( py) . eq ( & py. None ( ) ) ? {
109
109
return Ok ( serde_json:: Value :: Null ) ;
110
110
}
111
111
@@ -117,7 +117,7 @@ fn to_json(py: Python, obj: &PyObject) -> Result<serde_json::Value, PyCanonicalJ
117
117
return_cast ! ( PyDict , |x: & PyDict | {
118
118
let mut map = serde_json:: Map :: new( ) ;
119
119
for ( key_obj, value) in x. iter( ) {
120
- let key = if key_obj. eq( py. None ( ) . as_ref ( py) ) ? {
120
+ let key = if key_obj. eq( py. None ( ) . bind ( py) ) ? {
121
121
Ok ( "null" . to_string( ) )
122
122
} else if let Ok ( val) = key_obj. extract:: <bool >( ) {
123
123
Ok ( if val {
@@ -131,7 +131,7 @@ fn to_json(py: Python, obj: &PyObject) -> Result<serde_json::Value, PyCanonicalJ
131
131
Err ( PyCanonicalJSONError :: DictKeyNotSerializable {
132
132
typename: key_obj
133
133
. to_object( py)
134
- . as_ref ( py)
134
+ . bind ( py)
135
135
. get_type( )
136
136
. name( ) ?
137
137
. to_string( ) ,
@@ -165,6 +165,6 @@ fn to_json(py: Python, obj: &PyObject) -> Result<serde_json::Value, PyCanonicalJ
165
165
166
166
// At this point we can't cast it, set up the error object
167
167
Err ( PyCanonicalJSONError :: InvalidCast {
168
- typename : obj. as_ref ( py) . get_type ( ) . name ( ) ?. to_string ( ) ,
168
+ typename : obj. bind ( py) . get_type ( ) . name ( ) ?. to_string ( ) ,
169
169
} )
170
170
}
0 commit comments