{"action":"created","issue":{"url":"https://api.github.com/repos/micropython/micropython/issues/1675","labels_url":"https://api.github.com/repos/micropython/micropython/issues/1675/labels{/name}","comments_url":"https://api.github.com/repos/micropython/micropython/issues/1675/comments","events_url":"https://api.github.com/repos/micropython/micropython/issues/1675/events","html_url":"https://github.com/micropython/micropython/issues/1675","id":120107917,"number":1675,"title":"Problem resolving classes with __call__ (eg: pyb.Pin)","user":{"login":"ryannathans","id":1307375,"avatar_url":"https://avatars.githubusercontent.com/u/1307375?v=3","gravatar_id":"","url":"https://api.github.com/users/ryannathans","html_url":"https://github.com/ryannathans","followers_url":"https://api.github.com/users/ryannathans/followers","following_url":"https://api.github.com/users/ryannathans/following{/other_user}","gists_url":"https://api.github.com/users/ryannathans/gists{/gist_id}","starred_url":"https://api.github.com/users/ryannathans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryannathans/subscriptions","organizations_url":"https://api.github.com/users/ryannathans/orgs","repos_url":"https://api.github.com/users/ryannathans/repos","events_url":"https://api.github.com/users/ryannathans/events{/privacy}","received_events_url":"https://api.github.com/users/ryannathans/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-12-03T07:05:14Z","updated_at":"2015-12-05T09:41:01Z","closed_at":null,"body":"Using a micropython compiled today and my previously error free code, throws an exception on every boot. Swapping back to a my micropython compiled from october and the code runs without any issue.\r\n\r\n<trace here>\r\nAttributeError: 'bound_method' object has no attribute 'low'\r\n\r\noffending line is pin.low() or a pin.high()\r\n\r\nbelow is a simplification of the code that causes the error, with everything that seems to be unrelated stripped out. I haven't run the below, it serves merely as a generic demonstration. (I don't currently have a device with me to test)\r\n``` python\r\nimport pyb\r\nfrom baseobject import BaseObject\r\nimport consts\r\nimport functions\r\n\r\nclass MyObject (BaseObject):\r\n    if consts.DEVICE_TYPE == \"a\":\r\n        uart = pyb.UART(2, baudrate=19200, read_buf_len=2048)\r\n        sleep_pin = pyb.Pin(\"C2\", mode=pyb.Pin.OUT_PP)\r\n        mode_pin = pyb.Pin(\"C3\", mode=pyb.Pin.OUT_PP)\r\n        reset_pin = pyb.Pin(\"C4\", mode=pyb.Pin.OUT_PP)\r\n        #sleep_pin.high <--- PERFORMING THIS HERE WORKS IN THE NEW MICROPYTHON\r\n    elif consts.DEVICE_TYPE == \"b\":\r\n        uart = pyb.UART(2, baudrate=19200, read_buf_len=2048, timeout=2)\r\n        sleep_pin = pyb.Pin(\"A2\", mode=pyb.Pin.OUT_PP)\r\n        mode_pin = pyb.Pin(\"B3\", mode=pyb.Pin.OUT_PP)\r\n        reset_pin = pyb.Pin(\"C4\", mode=pyb.Pin.OUT_PP)\r\n        \r\n    def _reset_registers(self, register):\r\n        self.mode_pin.high() #<--- THESE THROW AN EXCEPTION IN THE NEW MICROPYTHON\r\n        self.uart.write(consts.default_registers[register])\r\n        self.mode_pin.low()  #<---\r\n     \r\n    def prepare(self):\r\n        super().prepare()\r\n        self.sleep_pin.high() #<--- THESE THROW AN EXCEPTION IN THE NEW MICROPYTHON\r\n        self.reset_pin.high() #<---\r\n        self.mode_pin.low()   #<---\r\n    \r\n    def run(self):\r\n        self.reset_pin.low()  #<--- THESE THROW AN EXCEPTION IN THE NEW MICROPYTHON\r\n        pyb.delay(1000)\r\n        self.reset_pin.high() #<---\r\n        while True:\r\n            a = self.uart.readall()\r\n            yield functions.doSomethingWith(a)\r\n\r\nMyObject()\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/micropython/micropython/issues/comments/162167614","html_url":"https://github.com/micropython/micropython/issues/1675#issuecomment-162167614","issue_url":"https://api.github.com/repos/micropython/micropython/issues/1675","id":162167614,"user":{"login":"ryannathans","id":1307375,"avatar_url":"https://avatars.githubusercontent.com/u/1307375?v=3","gravatar_id":"","url":"https://api.github.com/users/ryannathans","html_url":"https://github.com/ryannathans","followers_url":"https://api.github.com/users/ryannathans/followers","following_url":"https://api.github.com/users/ryannathans/following{/other_user}","gists_url":"https://api.github.com/users/ryannathans/gists{/gist_id}","starred_url":"https://api.github.com/users/ryannathans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryannathans/subscriptions","organizations_url":"https://api.github.com/users/ryannathans/orgs","repos_url":"https://api.github.com/users/ryannathans/repos","events_url":"https://api.github.com/users/ryannathans/events{/privacy}","received_events_url":"https://api.github.com/users/ryannathans/received_events","type":"User","site_admin":false},"created_at":"2015-12-05T09:41:01Z","updated_at":"2015-12-05T09:41:01Z","body":"Writing this for my own sanity...\r\n\r\nA class member that is an instance of an object with a __call__ method incorrectly resolves as a bound_method.\r\n\r\nA class member that is a class with a __call__ method resolves correctly.\r\n\r\nAn attribute of an instance of a class where the attribute is an instance of an object with a __call__ method resolves correctly.\r\n\r\nDirectly calling an instance of a class that has a __call__ method works correctly, instance is an object.\r\n\r\nDirectly calling an attribute of an object where the attribute is an instance of a class that has a __call__ method works correctly.\r\n\r\nCalling a class member that is an instance of a class that has a __call__ does not work correctly and displays the error TypeError: function takes 2 positional arguments but 3 were given\r\n\r\nConclusion: where class members are instances of an object and that object has a __call__ method, the class member resolves incorrectly as a bound method. Additionally, the call does not work in these cases. See above TypeError. "}}