Skip to content

Commit 0a4c9b5

Browse files
committed
Replace as_ref(py) with Bound APIs
1 parent f04ad56 commit 0a4c9b5

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/err/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ impl PyErrArguments for PyDowncastErrorArguments {
957957
format!(
958958
"'{}' object cannot be converted to '{}'",
959959
self.from
960-
.as_ref(py)
960+
.bind(py)
961961
.qualname()
962962
.as_deref()
963963
.unwrap_or("<failed to extract type name>"),

src/pyclass/create_type_object.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use crate::{
1111
pymethods::{get_doc, get_name, Getter, Setter},
1212
trampoline::trampoline,
1313
},
14+
types::typeobject::PyTypeMethods,
1415
types::PyType,
1516
Py, PyCell, PyClass, PyGetterDef, PyMethodDefType, PyResult, PySetterDef, PyTypeInfo, Python,
1617
};
@@ -435,7 +436,7 @@ impl PyTypeBuilder {
435436
bpo_45315_workaround(py, class_name);
436437

437438
for cleanup in std::mem::take(&mut self.cleanup) {
438-
cleanup(&self, type_object.as_ref(py).as_type_ptr());
439+
cleanup(&self, type_object.bind(py).as_type_ptr());
439440
}
440441

441442
Ok(PyClassTypeObject {

tests/test_methods.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl ClassMethod {
7474
#[classmethod]
7575
/// Test class method.
7676
fn method(cls: &Bound<'_, PyType>) -> PyResult<String> {
77-
Ok(format!("{}.method()!", cls.as_gil_ref().qualname()?))
77+
Ok(format!("{}.method()!", cls.qualname()?))
7878
}
7979

8080
#[classmethod]
@@ -85,10 +85,8 @@ impl ClassMethod {
8585

8686
#[classmethod]
8787
fn method_owned(cls: Py<PyType>) -> PyResult<String> {
88-
Ok(format!(
89-
"{}.method_owned()!",
90-
Python::with_gil(|gil| cls.as_ref(gil).qualname())?
91-
))
88+
let qualname = Python::with_gil(|gil| cls.bind(gil).qualname())?;
89+
Ok(format!("{}.method_owned()!", qualname))
9290
}
9391
}
9492

0 commit comments

Comments
 (0)