|
114 | 114 | >>> g(*Nothing()) |
115 | 115 | Traceback (most recent call last): |
116 | 116 | ... |
117 | | - TypeError: g() argument after * must be a sequence, not Nothing |
| 117 | + TypeError: g() argument after * must be an iterable, not Nothing |
118 | 118 |
|
119 | 119 | >>> class Nothing: |
120 | 120 | ... def __len__(self): return 5 |
|
123 | 123 | >>> g(*Nothing()) |
124 | 124 | Traceback (most recent call last): |
125 | 125 | ... |
126 | | - TypeError: g() argument after * must be a sequence, not Nothing |
| 126 | + TypeError: g() argument after * must be an iterable, not Nothing |
127 | 127 |
|
128 | 128 | >>> class Nothing(): |
129 | 129 | ... def __len__(self): return 5 |
|
149 | 149 | >>> g(*Nothing()) |
150 | 150 | 0 (1, 2, 3) {} |
151 | 151 |
|
| 152 | +Check for issue #4806: Does a TypeError in a generator get propagated with the |
| 153 | +right error message? (Also check with other iterables.) |
| 154 | +
|
| 155 | + >>> def broken(): raise TypeError("myerror") |
| 156 | + ... |
| 157 | +
|
| 158 | + >>> g(*(broken() for i in range(1))) |
| 159 | + Traceback (most recent call last): |
| 160 | + ... |
| 161 | + TypeError: myerror |
| 162 | +
|
| 163 | + >>> class BrokenIterable1: |
| 164 | + ... def __iter__(self): |
| 165 | + ... raise TypeError('myerror') |
| 166 | + ... |
| 167 | + >>> g(*BrokenIterable1()) |
| 168 | + Traceback (most recent call last): |
| 169 | + ... |
| 170 | + TypeError: myerror |
| 171 | +
|
| 172 | + >>> class BrokenIterable2: |
| 173 | + ... def __iter__(self): |
| 174 | + ... yield 0 |
| 175 | + ... raise TypeError('myerror') |
| 176 | + ... |
| 177 | + >>> g(*BrokenIterable2()) |
| 178 | + Traceback (most recent call last): |
| 179 | + ... |
| 180 | + TypeError: myerror |
| 181 | +
|
| 182 | + >>> class BrokenSequence: |
| 183 | + ... def __getitem__(self, idx): |
| 184 | + ... raise TypeError('myerror') |
| 185 | + ... |
| 186 | + >>> g(*BrokenSequence()) |
| 187 | + Traceback (most recent call last): |
| 188 | + ... |
| 189 | + TypeError: myerror |
| 190 | +
|
152 | 191 | Make sure that the function doesn't stomp the dictionary |
153 | 192 |
|
154 | 193 | >>> d = {'a': 1, 'b': 2, 'c': 3} |
|
188 | 227 | >>> h(*h) |
189 | 228 | Traceback (most recent call last): |
190 | 229 | ... |
191 | | - TypeError: h() argument after * must be a sequence, not function |
| 230 | + TypeError: h() argument after * must be an iterable, not function |
192 | 231 |
|
193 | 232 | >>> dir(*h) |
194 | 233 | Traceback (most recent call last): |
195 | 234 | ... |
196 | | - TypeError: dir() argument after * must be a sequence, not function |
| 235 | + TypeError: dir() argument after * must be an iterable, not function |
197 | 236 |
|
198 | 237 | >>> None(*h) |
199 | 238 | Traceback (most recent call last): |
200 | 239 | ... |
201 | | - TypeError: NoneType object argument after * must be a sequence, \ |
| 240 | + TypeError: NoneType object argument after * must be an iterable, \ |
202 | 241 | not function |
203 | 242 |
|
204 | 243 | >>> h(**h) |
|
0 commit comments