Closed majorgreys closed 4 years ago
What versions of Python is this occurring with?
The intent of the code in wrapt was doing the correct thing, the problem was that it was not applying it to the first lookup when doing recursive lookups on the path in resolve_path()
. It did the correct thing for nested path elements. So just tweaked the code to do it on the first lookup as well, rather than wholesale replacing what was done by the use of inspect.getattr_static()
. I'll review at another time whether inspect.getattr_static()
should be used if a reason comes up for it. Fixed in 1.12.1 of wrapt.
I am investigating an issue with how
wrapt
behaves when wrapping a staticmethod.To illustrate, let's start with the simple case and wrap the function to see the error:
Calling the function on an instance fails after wrapping:
If I instead wrap the function on the instance, the wrapper works as expected on the instance.
Looking at wrappers.py, the helper function
resolve_path
usesgetattr
to access the class attribute.If instead I use
inspect.getattr_static
to access the class attribute and then apply the wrapper as a patch, calling function on the instance does not raise an exception:Is this a correct workaround for wrapping staticmethods?
I can open a PR with changes if in fact the actual behavior I am finding is not what is expected.