Skip to content

Do not access attributes that don't match the method selector regex #14

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

Merged
merged 2 commits into from
Apr 1, 2020

Conversation

jdelic
Copy link
Contributor

@jdelic jdelic commented Jul 19, 2019

Only evaluate attributes after we know they match the method selector.

Otherwise properties on objects might trigger even though they're not matched by an aspect. Calling getattr is unavoidable for those attributes that do match the method selector, but we can avoid reading unrelated attributes.

Sometimes developers do stupid things when attributes are read, like going to the network to read a remote API to get the value. PyGithub, for example, does that. So the order of these instructions, i.e. when precisely we access attributes to apply aspects can make a huge difference.

…. Otherwise properties on objects might trigger even though they're not matched by an aspect. It's unavoidable for those attributes that do match the method selector, but we don't have to read unrelated attributes.
@ionelmc
Copy link
Owner

ionelmc commented Jul 19, 2019

Alright, please also update authors/changelog.rst.

@jdelic
Copy link
Contributor Author

jdelic commented Jul 19, 2019

@ionelmc

Alright, please also update authors/changelog.rst.

whoops. Done. I guess the CI needs some love too :/

@ionelmc
Copy link
Owner

ionelmc commented Jul 20, 2019

I'll fix that, looks like some configuration is too old.

@ionelmc ionelmc merged commit 66efa2e into ionelmc:master Apr 1, 2020
@ionelmc
Copy link
Owner

ionelmc commented Apr 1, 2020

Looks like I forgot about this. There will be a release soonish.

bmwiedemann referenced this pull request in bmwiedemann/openSUSE Apr 27, 2020
https://build.opensuse.org/request/show/796582
by user scarabeus_iv + dimstar_suse
- update to 1.5.0
  * Fixed ``weave`` to stop reading attributes that don't match the method selector.
    Contributed by Jonas Maurus in `#14 <https://github.com/ionelmc/python-aspectlib/pull/14>`_.
  * Added support for Python 3.7 and 3.8 (``async def`` functions and generators).
  * Added a convenience ``weave`` fixture for pytest.
- Launch tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants