Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump pyo3 to 0.17.1 #236

Merged
merged 9 commits into from
Aug 30, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
getattr needs IntoPy<Py<PyString>> now
  • Loading branch information
PrettyWood committed Aug 29, 2022
commit bfc6a453670ebd2b0bbab90e1632445b05882647
13 changes: 5 additions & 8 deletions src/lookup_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ impl LookupKey {

pub fn py_get_attr<'data, 's>(&'s self, obj: &'data PyAny) -> PyResult<Option<(&'s str, &'data PyAny)>> {
match self {
LookupKey::Simple(key, py_key) => match py_get_attrs(obj, &py_key)? {
LookupKey::Simple(key, py_key) => match py_get_attrs(obj, py_key)? {
Some(value) => Ok(Some((key, value))),
None => Ok(None),
},
LookupKey::Choice(key1, key2, py_key1, py_key2) => match py_get_attrs(obj, &py_key1)? {
LookupKey::Choice(key1, key2, py_key1, py_key2) => match py_get_attrs(obj, py_key1)? {
Some(value) => Ok(Some((key1, value))),
None => match py_get_attrs(obj, &py_key2)? {
None => match py_get_attrs(obj, py_key2)? {
Some(value) => Ok(Some((key2, value))),
None => Ok(None),
},
Expand Down Expand Up @@ -302,11 +302,8 @@ impl PathItem {

/// wrapper around `getattr` that returns `Ok(None)` for attribute errors, but returns other errors
/// We dont check `try_from_attributes` because that check was performed on the top level object before we got here
fn py_get_attrs<N>(obj: &PyAny, attr_name: N) -> PyResult<Option<&PyAny>>
where
N: ToPyObject,
{
match obj.getattr(attr_name) {
fn py_get_attrs<'a, 'b>(obj: &'a PyAny, attr_name: &'b Py<PyString>) -> PyResult<Option<&'a PyAny>> {
match obj.getattr(attr_name.extract::<&PyString>(obj.py())?) {
Ok(attr) => Ok(Some(attr)),
Err(err) => {
if err.get_type(obj.py()).is_subclass_of::<PyAttributeError>()? {
Expand Down