File: test68.py

package info (click to toggle)
pychecker 0.8.19-10
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,484 kB
  • ctags: 2,114
  • sloc: python: 9,968; sh: 98; makefile: 13
file content (170 lines) | stat: -rw-r--r-- 2,903 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
'test implicit returns'

__pychecker__ = 'implicitreturns'

def func1(x):
    'should not produce a warning'
    if x == 1:
        return 1
    return 0

def func2(x):
    'should produce a warning'
    if x == 1:
        return 1

def func3(x):
    'should not produce a warning'
    while 1:
        if x == 1:
            return 1
        x = x / 2
    return 0

def func4(x):
    'should not produce a warning'
    while 1:
        if x == 1:
            return 1
        x = x / 2

def func5(x):
    'should not produce a warning'
    while 1:
        if x == 1:
            return 1
    return 0

def func6(x):
    'should produce a warning'
    while 1:
        if x == 1:
            return 1
        break

def func7(x):
    'should not produce a warning'
    try:
        print x
        return 2
    except:
        pass
    return 0

def func8(x):
    'should produce a warning'
    try:
        if x == 1:
            return 3
        if x == 2:
            return 6
    except:
        pass

def func9(x):
    'should not produce a warning'
    try:
        return x
    except:
        return 0

def func10(x):
    'should not produce a warning'
    if x:
        raise ValueError

def func11(x):
    'should not produce a warning'
    if x:
        raise ValueError
    return 5

def func12(x):
    'should not produce a warning'
    raise ValueError, 'test'

def func13(x):
    'should not produce a warning'
    if x == 1:
        return 1
    else:
        return 0

def func14(x):
    'should not produce a warning'
    try:
        if x == 1:
            return 3
        return 6
    except:
        raise

def func15(x):
    'should not produce a warning'
    try:
        return x.j
    except AttributeError:
        return 0

def func16(x):
    'should not produce a warning'
    try:
        return x.j
    except AttributeError:
        raise

def func17(x):
    'should not produce a warning'
    try:
        return x.j
    except (AttributeError, KeyError, IndexError):
        return 0

def func18(x):
    if x == 'n':
        return x
    if x != 'j':
        raise AttributeError

def func19(x):
    'should not produce a warning'
    while 1:
        if x:
            x = x + 1
        return 1

def func20(x):
    'should produce a warning'
    while 1:
        if x:
            break
        return 1

def func21(x):
    'should not produce a warning'
    try:
        if x == 1:
            return 3
        return 6
    finally:
        print 'do nothing'

def func22(x):
    'should not produce a warning'
    while 1:
        for _ in range(10) :
            x = x / 2
            break
        return 1

def catchup(slave, image, inProgress):
    d = func1.bogus()
    def next_func():
        defer = slave.call('', image.next())
        try:
            defer.add(d.errback)
        except:
            slave.call(inProgress)
    next_func()
    return d