Skip to content

Commit 2665b40

Browse files
committed
Remove deprecated as_ref(py)
1 parent f2851e3 commit 2665b40

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl From<PyCanonicalJSONError> for pyo3::PyErr {
5757

5858
/// A canonical JSON serializer written in Rust
5959
#[pymodule]
60-
fn canonicaljson(_py: Python, m: &PyModule) -> PyResult<()> {
60+
fn canonicaljson(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
6161
m.add("__version__", env!("CARGO_PKG_VERSION"))?;
6262

6363
m.add_wrapped(wrap_pyfunction!(dump))?;
@@ -105,7 +105,7 @@ fn to_json(py: Python, obj: &PyObject) -> Result<serde_json::Value, PyCanonicalJ
105105
};
106106
}
107107

108-
if obj.as_ref(py).eq(&py.None())? {
108+
if obj.bind(py).eq(&py.None())? {
109109
return Ok(serde_json::Value::Null);
110110
}
111111

@@ -117,7 +117,7 @@ fn to_json(py: Python, obj: &PyObject) -> Result<serde_json::Value, PyCanonicalJ
117117
return_cast!(PyDict, |x: &PyDict| {
118118
let mut map = serde_json::Map::new();
119119
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))? {
121121
Ok("null".to_string())
122122
} else if let Ok(val) = key_obj.extract::<bool>() {
123123
Ok(if val {
@@ -131,7 +131,7 @@ fn to_json(py: Python, obj: &PyObject) -> Result<serde_json::Value, PyCanonicalJ
131131
Err(PyCanonicalJSONError::DictKeyNotSerializable {
132132
typename: key_obj
133133
.to_object(py)
134-
.as_ref(py)
134+
.bind(py)
135135
.get_type()
136136
.name()?
137137
.to_string(),
@@ -165,6 +165,6 @@ fn to_json(py: Python, obj: &PyObject) -> Result<serde_json::Value, PyCanonicalJ
165165

166166
// At this point we can't cast it, set up the error object
167167
Err(PyCanonicalJSONError::InvalidCast {
168-
typename: obj.as_ref(py).get_type().name()?.to_string(),
168+
typename: obj.bind(py).get_type().name()?.to_string(),
169169
})
170170
}

0 commit comments

Comments
 (0)