Statistics
| Revision:

gvsig-scripting / org.gvsig.scripting / trunk / org.gvsig.scripting / org.gvsig.scripting.app / org.gvsig.scripting.app.mainplugin / src / main / resources-plugin / scripting / lib / pylint / test / input / func_w0623_py_30.py @ 745

History | View | Annotate | Download (1.39 KB)

1
"""Test for W0623, overwriting names in exception handlers."""
2
# pylint: disable=broad-except,bare-except,print-statement,no-absolute-import,duplicate-except
3
import exceptions
4

    
5
__revision__ = ''
6

    
7
class MyError(Exception):
8
    """Special exception class."""
9
    pass
10

    
11

    
12
def some_function():
13
    """A function."""
14
    exc = None
15

    
16
    try:
17
        {}["a"]
18
    except KeyError, exceptions.RuntimeError: # W0623
19
        pass
20
    except KeyError, OSError: # W0623
21
        pass
22
    except KeyError, MyError: # W0623
23
        pass
24
    except KeyError, exc: # this is fine
25
        print exc
26
    except KeyError, exc1: # this is fine
27
        print exc1
28
    except KeyError, FOO: # C0103
29
        print FOO
30

    
31
    try:
32
        pass
33
    except KeyError, exc1: # this is fine
34
        print exc1
35

    
36
class MyOtherError(Exception):
37
    """Special exception class."""
38
    pass
39

    
40

    
41
exc3 = None
42

    
43
try:
44
    pass
45
except KeyError, exceptions.RuntimeError: # W0623
46
    pass
47
except KeyError, exceptions.RuntimeError.args: # W0623
48
    pass
49
except KeyError, OSError: # W0623
50
    pass
51
except KeyError, MyOtherError: # W0623
52
    pass
53
except KeyError, exc3: # this is fine
54
    print exc3
55
except KeyError, exc4: # this is fine
56
    print exc4
57
except KeyError, OOPS: # C0103
58
    print OOPS
59

    
60
try:
61
    pass
62
except KeyError, exc4: # this is fine
63
    print exc4
64
except IOError, exc5: # this is fine
65
    print exc5
66
except MyOtherError, exc5: # this is fine
67
    print exc5