Replace as_ref(py) with Bound APIs (#3863)
This commit is contained in:
parent
9a36b50789
commit
76dabd4e60
|
@ -957,7 +957,7 @@ impl PyErrArguments for PyDowncastErrorArguments {
|
|||
format!(
|
||||
"'{}' object cannot be converted to '{}'",
|
||||
self.from
|
||||
.as_ref(py)
|
||||
.bind(py)
|
||||
.qualname()
|
||||
.as_deref()
|
||||
.unwrap_or("<failed to extract type name>"),
|
||||
|
|
|
@ -11,6 +11,7 @@ use crate::{
|
|||
pymethods::{get_doc, get_name, Getter, Setter},
|
||||
trampoline::trampoline,
|
||||
},
|
||||
types::typeobject::PyTypeMethods,
|
||||
types::PyType,
|
||||
Py, PyCell, PyClass, PyGetterDef, PyMethodDefType, PyResult, PySetterDef, PyTypeInfo, Python,
|
||||
};
|
||||
|
@ -434,7 +435,7 @@ impl PyTypeBuilder {
|
|||
bpo_45315_workaround(py, class_name);
|
||||
|
||||
for cleanup in std::mem::take(&mut self.cleanup) {
|
||||
cleanup(&self, type_object.as_ref(py).as_type_ptr());
|
||||
cleanup(&self, type_object.bind(py).as_type_ptr());
|
||||
}
|
||||
|
||||
Ok(PyClassTypeObject {
|
||||
|
|
|
@ -73,7 +73,7 @@ impl ClassMethod {
|
|||
#[classmethod]
|
||||
/// Test class method.
|
||||
fn method(cls: &Bound<'_, PyType>) -> PyResult<String> {
|
||||
Ok(format!("{}.method()!", cls.as_gil_ref().qualname()?))
|
||||
Ok(format!("{}.method()!", cls.qualname()?))
|
||||
}
|
||||
|
||||
#[classmethod]
|
||||
|
@ -84,10 +84,8 @@ impl ClassMethod {
|
|||
|
||||
#[classmethod]
|
||||
fn method_owned(cls: Py<PyType>) -> PyResult<String> {
|
||||
Ok(format!(
|
||||
"{}.method_owned()!",
|
||||
Python::with_gil(|gil| cls.as_ref(gil).qualname())?
|
||||
))
|
||||
let qualname = Python::with_gil(|gil| cls.bind(gil).qualname())?;
|
||||
Ok(format!("{}.method_owned()!", qualname))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue