{"action":"created","issue":{"url":"https://api.github.com/repos/GadgetReactor/pyHS100/issues/165","repository_url":"https://api.github.com/repos/GadgetReactor/pyHS100","labels_url":"https://api.github.com/repos/GadgetReactor/pyHS100/issues/165/labels{/name}","comments_url":"https://api.github.com/repos/GadgetReactor/pyHS100/issues/165/comments","events_url":"https://api.github.com/repos/GadgetReactor/pyHS100/issues/165/events","html_url":"https://github.com/GadgetReactor/pyHS100/issues/165","id":421259100,"node_id":"MDU6SXNzdWU0MjEyNTkxMDA=","number":165,"title":"Crash when __repr__ is called on SmartStrip device","user":{"login":"scootdj","id":13542356,"node_id":"MDQ6VXNlcjEzNTQyMzU2","avatar_url":"https://avatars1.githubusercontent.com/u/13542356?v=4","gravatar_id":"","url":"https://api.github.com/users/scootdj","html_url":"https://github.com/scootdj","followers_url":"https://api.github.com/users/scootdj/followers","following_url":"https://api.github.com/users/scootdj/following{/other_user}","gists_url":"https://api.github.com/users/scootdj/gists{/gist_id}","starred_url":"https://api.github.com/users/scootdj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scootdj/subscriptions","organizations_url":"https://api.github.com/users/scootdj/orgs","repos_url":"https://api.github.com/users/scootdj/repos","events_url":"https://api.github.com/users/scootdj/events{/privacy}","received_events_url":"https://api.github.com/users/scootdj/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2019-03-14T21:46:13Z","updated_at":"2019-03-29T22:15:24Z","closed_at":null,"author_association":"NONE","body":"SmartDevice defines a __repr__ that calls self.is_on.  \r\n\r\nis_on must be implemented by subclasses.  SmartStrip defines is_on differently with an additional parameter (index) and a different return value 'Any'. \r\n\r\nInfinite recursion happens when __repr__ tries to call the SmartStrip.is_on.  Because the value returned by SmartDevice.is_on is not a string, a recursive call to __repr__ happens.\r\n\r\nI have worked around it by changing SmartDevice.__repr__ to:\r\n\r\ndef __repr__(self):\r\n        if isinstance(self.is_on, str):\r\n            is_on = self.is_on\r\n        else:\r\n            is_on = self.is_on()\r\n        return \"<%s at %s (%s), is_on: %s - dev specific: %s>\" % (\r\n            self.__class__.__name__,\r\n            self.host,\r\n            self.alias,\r\n            is_on,\r\n            self.state_information)"},"comment":{"url":"https://api.github.com/repos/GadgetReactor/pyHS100/issues/comments/478165851","html_url":"https://github.com/GadgetReactor/pyHS100/issues/165#issuecomment-478165851","issue_url":"https://api.github.com/repos/GadgetReactor/pyHS100/issues/165","id":478165851,"node_id":"MDEyOklzc3VlQ29tbWVudDQ3ODE2NTg1MQ==","user":{"login":"eode","id":2475983,"node_id":"MDQ6VXNlcjI0NzU5ODM=","avatar_url":"https://avatars3.githubusercontent.com/u/2475983?v=4","gravatar_id":"","url":"https://api.github.com/users/eode","html_url":"https://github.com/eode","followers_url":"https://api.github.com/users/eode/followers","following_url":"https://api.github.com/users/eode/following{/other_user}","gists_url":"https://api.github.com/users/eode/gists{/gist_id}","starred_url":"https://api.github.com/users/eode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eode/subscriptions","organizations_url":"https://api.github.com/users/eode/orgs","repos_url":"https://api.github.com/users/eode/repos","events_url":"https://api.github.com/users/eode/events{/privacy}","received_events_url":"https://api.github.com/users/eode/received_events","type":"User","site_admin":false},"created_at":"2019-03-29T22:15:24Z","updated_at":"2019-03-29T22:15:24Z","author_association":"NONE","body":"Cleaned that up for copypasta, if anyone wants it.\r\n```python\r\ndef fixed_repr(self):\r\n    if isinstance(self.is_on, str):\r\n        is_on = self.is_on\r\n    else:\r\n        is_on = self.is_on()\r\n    return \"<%s at %s (%s), is_on: %s - dev specific: %s>\" % (\r\n        self.__class__.__name__,\r\n        self.host,\r\n        self.alias,\r\n        is_on,\r\n        self.state_information)\r\n\r\npyHS100.SmartStrip.__repr__ = fixed_repr\r\n```"}}
{"actor":{"display_login":"eode"}}