Traceback (most recent call last):
File "~/scratch/wrapt_bug.py", line 16, in <module>
print(type(A.add))
AttributeError: 'builtin_function_or_method' object has no attribute '__get__'
If the wrapt patches are removed (commenting out everything before line 9 (import operator)), the program runs as expected
Experimenting locally, I found that updating the condition from
if not inspect.isclass(self.__wrapped__):
if not inspect.isclass(self.__wrapped__) and not inspect.isbuiltin(self.__wrapped__):
passes my tests, which include more complex uses than the reproducer I showed. I don't have a very complete understanding of descriptors though, so I may be overlooking edge cases. My change to update the condition based on isbuiltin was inspired by this StackOverflow answer: https://stackoverflow.com/a/52140735 . Hopefully it helps guide you all if I misunderstood the response.
Lastly, I'm new to wrapt and tried to read through all the documentation before opening this issue. If I'm misusing the package, please let me know!
This issue is similar to #256 , but throws a different exception that might be easier to resolve.
Reproducer
Running this program gives
If the wrapt patches are removed (commenting out everything before line 9 (
import operator
)), the program runs as expectedAdditional Details
The
AttributeError
is being thrown on https://github.com/GrahamDumpleton/wrapt/blob/5c0997c0b5be36da5f621c3473c95f9efe14891e/src/wrapt/wrappers.py#L534Experimenting locally, I found that updating the condition from
passes my tests, which include more complex uses than the reproducer I showed. I don't have a very complete understanding of descriptors though, so I may be overlooking edge cases. My change to update the condition based on
isbuiltin
was inspired by this StackOverflow answer: https://stackoverflow.com/a/52140735 . Hopefully it helps guide you all if I misunderstood the response.Lastly, I'm new to wrapt and tried to read through all the documentation before opening this issue. If I'm misusing the package, please let me know!