bpo-38026: fix inspect.getattr_static#15676
Conversation
It should avoid dynamic lookup including `isinstance`. This is regression caused by pythonGH-5351.
| dict_attr = _shadowed_dict(klass) | ||
| if (dict_attr is _sentinel or | ||
| isinstance(dict_attr, types.MemberDescriptorType)): | ||
| type(dict_attr) is types.MemberDescriptorType): |
There was a problem hiding this comment.
I think It helps to comment on why we use type here.
There was a problem hiding this comment.
If it is required, every line in this function should have same comment. It will be too noisy...
There was a problem hiding this comment.
Maybe a link to the issue?
There was a problem hiding this comment.
Note that I merged because I didn't read the comment / docstring so I didn't notice dynamic lookup should be avoided. It's totally my mistake.
But note that It is not because I didn't notice isinstance cause dynamic lookup.
If we want to avoid this type of regression by adding comment, we need to add
# to avoid dynamic lookup comment on every line. It's nonsense...
|
Would be nice to add tests. |
Of course, but I am not metaprogramming expert so I don't know how to override |
|
Thanks @methane for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8. |
|
GH-15692 is a backport of this pull request to the 3.8 branch. |
It should avoid dynamic lookup including `isinstance`. This is a regression caused by pythonGH-5351. (cherry picked from commit 8f9cc87) Co-authored-by: Inada Naoki <songofacandy@gmail.com>
It should avoid dynamic lookup including `isinstance`. This is a regression caused by pythonGH-5351.
It should avoid dynamic lookup including `isinstance`. This is a regression caused by pythonGH-5351.
It should avoid dynamic lookup including `isinstance`. This is a regression caused by pythonGH-5351.
It should avoid dynamic lookup including
isinstance.This is a regression caused by #5351.
https://bugs.python.org/issue38026