mkapi icon indicating copy to clipboard operation
mkapi copied to clipboard

Use try-except instead of hasattr for detection of __wrapped__ and __pytest_wrapped__

Open pwwang opened this issue 5 years ago • 0 comments

https://github.com/daizutabi/mkapi/blob/6e0cf8f43adf1d5fe9008b751714817e694f88e3/mkapi/core/object.py#L201-L203

When some classes have improper or complicated __getattr__ implemented, this will raise some errors unexpectedly. We should use try-except instead:

try:
     obj.__wrapped__
    # Do something with obj.__wrapped__
    # or in else
except AttributeError:
    # no __wrapped__ attribute

pwwang avatar Sep 15 '20 00:09 pwwang