{"action":"created","issue":{"url":"https://api.github.com/repos/liqd/adhocracy3.mercator/issues/654","labels_url":"https://api.github.com/repos/liqd/adhocracy3.mercator/issues/654/labels{/name}","comments_url":"https://api.github.com/repos/liqd/adhocracy3.mercator/issues/654/comments","events_url":"https://api.github.com/repos/liqd/adhocracy3.mercator/issues/654/events","html_url":"https://github.com/liqd/adhocracy3.mercator/pull/654","id":56923089,"number":654,"title":"Fix: 'hasattr' might swallow exceptions","user":{"login":"joka","id":353982,"avatar_url":"https://avatars.githubusercontent.com/u/353982?v=3","gravatar_id":"","url":"https://api.github.com/users/joka","html_url":"https://github.com/joka","followers_url":"https://api.github.com/users/joka/followers","following_url":"https://api.github.com/users/joka/following{/other_user}","gists_url":"https://api.github.com/users/joka/gists{/gist_id}","starred_url":"https://api.github.com/users/joka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joka/subscriptions","organizations_url":"https://api.github.com/users/joka/orgs","repos_url":"https://api.github.com/users/joka/repos","events_url":"https://api.github.com/users/joka/events{/privacy}","received_events_url":"https://api.github.com/users/joka/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/liqd/adhocracy3.mercator/labels/backend","name":"backend","color":"bfe5bf"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-07T19:42:01Z","updated_at":"2015-02-09T09:30:42Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/liqd/adhocracy3.mercator/pulls/654","html_url":"https://github.com/liqd/adhocracy3.mercator/pull/654","diff_url":"https://github.com/liqd/adhocracy3.mercator/pull/654.diff","patch_url":"https://github.com/liqd/adhocracy3.mercator/pull/654.patch"},"body":"Python build in hasattr might hide Attribute and zodb exceptions:\r\n\r\nhttp://stackoverflow.com/questions/24971061/python-hasattr-vs-getattr\r\nhttps://dev.plone.org/ticket/3285\r\nhttp://mail.dzug.org/mailman/archives/zope/2006-October/002010.html\r\n\r\nTo be on the safe side we should just not use it."},"comment":{"url":"https://api.github.com/repos/liqd/adhocracy3.mercator/issues/comments/73479514","html_url":"https://github.com/liqd/adhocracy3.mercator/pull/654#issuecomment-73479514","issue_url":"https://api.github.com/repos/liqd/adhocracy3.mercator/issues/654","id":73479514,"user":{"login":"ChristianSi","id":4480899,"avatar_url":"https://avatars.githubusercontent.com/u/4480899?v=3","gravatar_id":"","url":"https://api.github.com/users/ChristianSi","html_url":"https://github.com/ChristianSi","followers_url":"https://api.github.com/users/ChristianSi/followers","following_url":"https://api.github.com/users/ChristianSi/following{/other_user}","gists_url":"https://api.github.com/users/ChristianSi/gists{/gist_id}","starred_url":"https://api.github.com/users/ChristianSi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChristianSi/subscriptions","organizations_url":"https://api.github.com/users/ChristianSi/orgs","repos_url":"https://api.github.com/users/ChristianSi/repos","events_url":"https://api.github.com/users/ChristianSi/events{/privacy}","received_events_url":"https://api.github.com/users/ChristianSi/received_events","type":"User","site_admin":false},"created_at":"2015-02-09T09:30:42Z","updated_at":"2015-02-09T09:30:42Z","body":"I think the bad behavior of `hasattr` was fixed by Python 3. In [Py2](https://docs.python.org/2/library/functions.html?highlight=hasattr#hasattr), it catches *all* exceptions thrown by `getattr` which is of course pretty bad. But in [Py 3](https://docs.python.org/3/library/functions.html?highlight=hasattr#hasattr), it only catches `AttributeError ` and thus should be safe to use.\r\n\r\nSo `hasattr` should be safe for us to use, but of course it cannot hurt using `getattr` with a default value instead -- in fact it's a bit cleaner, since it avoids raising and catching an exception."}}