alexmojaki/snoop

AttributeError on static method

rachmadaniHaryono opened this issue · 0 comments

Name: snoop
Version: 0.2.1

import snoop


class A:

    @snoop
    @staticmethod
    def print_hello():
        print('hello')


if __name__ == '__main__':
    A.print_hello()
$ python script.py
Traceback (most recent call last):
  File "script.py", line 5, in <module>
    class A:
  File "script.py", line 8, in A
    @staticmethod
  File "/home/q/envs/mitmproxy_image/lib/python3.6/site-packages/snoop/tracer.py", line 164, in __call__
    self.target_codes.add(function.__code__)
AttributeError: 'staticmethod' object has no attribute '__code__'

e: the fix is to put snoop after staticmethod decorator

    @staticmethod
    @snoop
    def print_hello():
        print('hello')