{"action":"closed","issue":{"url":"https://api.github.com/repos/PyCQA/pylint/issues/2174","repository_url":"https://api.github.com/repos/PyCQA/pylint","labels_url":"https://api.github.com/repos/PyCQA/pylint/issues/2174/labels{/name}","comments_url":"https://api.github.com/repos/PyCQA/pylint/issues/2174/comments","events_url":"https://api.github.com/repos/PyCQA/pylint/issues/2174/events","html_url":"https://github.com/PyCQA/pylint/issues/2174","id":330720668,"node_id":"MDU6SXNzdWUzMzA3MjA2Njg=","number":2174,"title":"duplicate-except warning for dynamic exception handling","user":{"login":"s-hertel","id":19572925,"node_id":"MDQ6VXNlcjE5NTcyOTI1","avatar_url":"https://avatars2.githubusercontent.com/u/19572925?v=4","gravatar_id":"","url":"https://api.github.com/users/s-hertel","html_url":"https://github.com/s-hertel","followers_url":"https://api.github.com/users/s-hertel/followers","following_url":"https://api.github.com/users/s-hertel/following{/other_user}","gists_url":"https://api.github.com/users/s-hertel/gists{/gist_id}","starred_url":"https://api.github.com/users/s-hertel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s-hertel/subscriptions","organizations_url":"https://api.github.com/users/s-hertel/orgs","repos_url":"https://api.github.com/users/s-hertel/repos","events_url":"https://api.github.com/users/s-hertel/events{/privacy}","received_events_url":"https://api.github.com/users/s-hertel/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-06-08T16:17:03Z","updated_at":"2018-06-18T05:36:58Z","closed_at":"2018-06-18T05:36:57Z","author_association":"NONE","body":"### Steps to reproduce\r\n```\r\nclass Foo(Exception):\r\n    \"\"\" Exception wrapper\r\n    \"\"\"\r\n    def __init__(self, code):\r\n        super(Foo, self).__init__()\r\n        self.response = {'Error': {'Code': code}}\r\n\r\n\r\ndef dynamic_exc(code):\r\n    \"\"\" Dynamically determine what exception\r\n    \"\"\"\r\n    import sys\r\n    dummy, exc, dummy = sys.exc_info()\r\n    if isinstance(exc, Foo) and exc.response['Error']['Code'] == code:\r\n        return Foo\r\n    return type('OtherException', (Exception,), {})\r\n\r\n\r\ntry:\r\n    raise Foo('403')\r\nexcept dynamic_exc('403') as ex:\r\n    print('The dynamic exception {0}'.format(ex))\r\nexcept Foo as ex:\r\n    print('Caught general Foo exception {0}'.format(ex))\r\n\r\n\r\ntry:\r\n    raise Foo('404')\r\nexcept dynamic_exc('403') as ex:\r\n    print('The dynamic exception {0}'.format(ex))\r\nexcept Foo as ex:\r\n    print('Caught general Foo exception {0}'.format(ex))\r\n```\r\n\r\n### Current behavior\r\n```\r\nW: 25, 7: Catching previously caught exception type Foo (duplicate-except)\r\nW: 33, 7: Catching previously caught exception type Foo (duplicate-except)\r\n```\r\npylint gives a duplicate-except warning for dynamic exceptions that may not be duplicates\r\n\r\n### Expected behavior\r\nI would expect differentiation between dynamically handled exceptions and static duplicates like below so warnings for dynamic exceptions can be turned off without masking static duplicates.\r\n```\r\ntry:\r\n    raise Foo('404')\r\nexcept Foo as ex:\r\n    print('Caught general Foo exception {0}'.format(ex))\r\nexcept Foo as ex:\r\n    print('Caught general Foo exception {0}'.format(ex))\r\n```\r\n\r\n### pylint --version output\r\n```\r\nNo config file found, using default configuration\r\npylint 1.9.2,\r\nastroid 1.6.5\r\nPython 3.6.0 (default, Aug  8 2017, 09:49:26)\r\n[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]\r\n```\r\n"}}
{"actor":{"display_login":"PCManticore"}}