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