File: w_uninitialized_exc.pyx

package info (click to toggle)
cython 3.0.11%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 19,092 kB
  • sloc: python: 83,539; ansic: 18,831; cpp: 1,402; xml: 1,031; javascript: 511; makefile: 403; sh: 204; sed: 11
file content (125 lines) | stat: -rw-r--r-- 2,274 bytes parent folder | download | duplicates (5)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# cython: warn.maybe_uninitialized=True
# mode: error
# tag: werror

def exc_target():
    try:
        {}['foo']
    except KeyError, e:
        pass
    except IndexError, i:
        pass
    return e, i

def exc_body():
    try:
        a = 1
    except Exception:
        pass
    return a

def exc_else_pos():
    try:
        pass
    except Exception, e:
        pass
    else:
        e = 1
    return e

def exc_body_pos(d):
    try:
        a = d['foo']
    except KeyError:
        a = None
    return a

def exc_pos():
    try:
        a = 1
    except Exception:
        a = 1
    return a

def exc_finally():
    try:
        a = 1
    finally:
        pass
    return a

def exc_finally2():
    try:
        pass
    finally:
        a = 1
    return a


def exc_assmt_except(a):
    try:
        x = a
    except:
        return x

def exc_assmt_finaly(a):
    try:
        x = a
    except:
        return x

def raise_stat(a):
    try:
        if a < 0:
            raise IndexError
    except IndexError:
        oops = 1
    print oops

def try_loop(args):
    try:
        x = 0
        for i in args:
            if i is 0:
                continue
            elif i is None:
                break
            elif i is False:
                return
            i()
    except ValueError:
        x = 1
    finally:
        return x

def try_finally(a):
    try:
        for i in a:
            if i > 0:
                x = 1
    finally:
        return x

def try_finally_nested(m):
    try:
        try:
            try:
                f = m()
            except:
                pass
        finally:
            pass
    except:
        print f

_ERRORS = """
12:11: local variable 'e' might be referenced before assignment
12:14: local variable 'i' might be referenced before assignment
19:11: local variable 'a' might be referenced before assignment
63:15: local variable 'x' might be referenced before assignment
69:15: local variable 'x' might be referenced before assignment
77:10: local variable 'oops' might be referenced before assignment
93:15: local variable 'x' might be referenced before assignment
101:15: local variable 'x' might be referenced before assignment
113:14: local variable 'f' might be referenced before assignment
"""