Address review comments
This commit is contained in:
parent
0678f11266
commit
dc4f114d67
|
@ -33,11 +33,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- `wrap_pyfunction!` can now wrap a `#[pyfunction]` which is implemented in a different Rust module or crate. [#2091](https://github.com/PyO3/pyo3/pull/2091)
|
||||
- Add `PyAny::contains` method (`in` operator for `PyAny`). [#2115](https://github.com/PyO3/pyo3/pull/2115)
|
||||
- Add `PyMapping::contains` method (`in` operator for `PyMapping`). [#2133](https://github.com/PyO3/pyo3/pull/2133)
|
||||
- Add support for the `__getattribute__` magic method. [#2187](https://github.com/PyO3/pyo3/pull/2187)
|
||||
- Add garbage collection magic methods `__traverse__` and `__clear__` to `#[pymethods]`. [#2159](https://github.com/PyO3/pyo3/pull/2159)
|
||||
- Add support for `from_py_with` on struct tuples and enums to override the default from-Python conversion. [#2181](https://github.com/PyO3/pyo3/pull/2181)
|
||||
- Add `eq`, `ne`, `lt`, `le`, `gt`, `ge` methods to `PyAny` that wrap `rich_compare`. [#2175](https://github.com/PyO3/pyo3/pull/2175)
|
||||
- Add `Py::is` and `PyAny::is` methods to check for object identity. [#2183](https://github.com/PyO3/pyo3/pull/2183)
|
||||
- Add support for the `__getattribute__` magic method. [#2187](https://github.com/PyO3/pyo3/pull/2187)
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
|
@ -210,8 +210,11 @@ slot_fragment_trait! {
|
|||
attr: *mut ffi::PyObject,
|
||||
) -> PyResult<*mut ffi::PyObject> {
|
||||
let res = ffi::PyObject_GenericGetAttr(slf, attr);
|
||||
if res.is_null() { Err(PyErr::fetch(py)) }
|
||||
else { Ok(res) }
|
||||
if res.is_null() {
|
||||
Err(PyErr::fetch(py))
|
||||
} else {
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -226,7 +229,9 @@ slot_fragment_trait! {
|
|||
_slf: *mut ffi::PyObject,
|
||||
attr: *mut ffi::PyObject,
|
||||
) -> PyResult<*mut ffi::PyObject> {
|
||||
Err(PyErr::new::<PyAttributeError, _>((Py::<PyAny>::from_owned_ptr(py, attr),)))
|
||||
Err(PyErr::new::<PyAttributeError, _>(
|
||||
(Py::<PyAny>::from_borrowed_ptr(py, attr),)
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -239,7 +244,6 @@ macro_rules! generate_pyclass_getattro_slot {
|
|||
attr: *mut $crate::ffi::PyObject,
|
||||
) -> *mut $crate::ffi::PyObject {
|
||||
use ::std::result::Result::*;
|
||||
use $crate::callback::IntoPyCallbackOutput;
|
||||
use $crate::impl_::pyclass::*;
|
||||
let gil = $crate::GILPool::new();
|
||||
let py = gil.python();
|
||||
|
@ -254,9 +258,9 @@ macro_rules! generate_pyclass_getattro_slot {
|
|||
// - If it fails with AttributeError, try __getattr__.
|
||||
// - If it fails otherwise, reraise.
|
||||
match collector.__getattribute__(py, _slf, attr) {
|
||||
Ok(obj) => obj.convert(py),
|
||||
Ok(obj) => Ok(obj),
|
||||
Err(e) if e.is_instance_of::<$crate::exceptions::PyAttributeError>(py) => {
|
||||
collector.__getattr__(py, _slf, attr).convert(py)
|
||||
collector.__getattr__(py, _slf, attr)
|
||||
}
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue