summaryrefslogtreecommitdiff
path: root/pylint/test/input/func_w0623_py_30.py
blob: cc8d36cf2b952837b8a2481f6d28a0eb027ee6ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""Test for W0623, overwriting names in exception handlers."""
# pylint: disable=broad-except,bare-except,print-statement,no-absolute-import,duplicate-except
import exceptions

__revision__ = ''

class MyError(Exception):
    """Special exception class."""
    pass


def some_function():
    """A function."""
    exc = None

    try:
        {}["a"]
    except KeyError, exceptions.RuntimeError: # W0623
        pass
    except KeyError, OSError: # W0623
        pass
    except KeyError, MyError: # W0623
        pass
    except KeyError, exc: # this is fine
        print exc
    except KeyError, exc1: # this is fine
        print exc1
    except KeyError, FOO: # C0103
        print FOO

    try:
        pass
    except KeyError, exc1: # this is fine
        print exc1

class MyOtherError(Exception):
    """Special exception class."""
    pass


exc3 = None

try:
    pass
except KeyError, exceptions.RuntimeError: # W0623
    pass
except KeyError, exceptions.RuntimeError.args: # W0623
    pass
except KeyError, OSError: # W0623
    pass
except KeyError, MyOtherError: # W0623
    pass
except KeyError, exc3: # this is fine
    print exc3
except KeyError, exc4: # this is fine
    print exc4
except KeyError, OOPS: # C0103
    print OOPS

try:
    pass
except KeyError, exc4: # this is fine
    print exc4
except IOError, exc5: # this is fine
    print exc5
except MyOtherError, exc5: # this is fine
    print exc5