Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork938
Commitf5dc1c4
committed
Expand "invalid hash" test to assert normal StopIteration
Returning an explicit value from a generator function causes thatvalue to be bound to the `value` attribute of the StopIterationexception. This is available as the result of "yield from" when itis used as an expression; or by explicitly catching StopIteration,binding the StopIteration exception to a variable, and accessingthe attribute. This feature of generators is rarely used.The `return iter([])` statement in Submodule.iter_items uses thisfeature, causing the resulting StopIteration exception object tohave a `value` attribute that refers to a separate second iteratorthat also yields no values (#1779).From context, this behavior is clearly not the goal; a bare returnstatement should be used here (which has the same effect except forthe `value` attribute of the StopIteration exception). The code hadused a bare return prior to82b131c (#1282), when `return` waschanged to `return iter([])`. That was part of a change that addednumerous type annotations. It looks like it was either a mistake,or possibly an attempt to work around an old bug in a static typechecker.This commit extends the test_iter_items_from_invalid_hash test toassert that the `value` attribute of the StopIteration is its usualdefault value of None. This commit only extends the test; it doesnot fix the bug.1 parent96fc354 commitf5dc1c4
1 file changed
+2
-1
lines changedLines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
696 | 696 |
| |
697 | 697 |
| |
698 | 698 |
| |
699 |
| - | |
| 699 | + | |
700 | 700 |
| |
| 701 | + | |
701 | 702 |
| |
702 | 703 |
| |
703 | 704 |
| |
|
0 commit comments
Comments
(0)