FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

py: Fix errors are suppressed in generator comprehensions by corona10 · Pull Request #38 · go-python/gpython · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .go  (1) .py  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
7 changes: 5 additions & 2 deletions py/sequence.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,13 @@ func Iterate(obj Object, fn func(Object) bool) error {
return err
}
for {
item, finished := Next(iterator)
if finished != nil {
item, err := Next(iterator)
Comment thread
corona10 marked this conversation as resolved.
if err == StopIteration {
break
}
if err != nil {
return err
}
if fn(item) {
break
}
Expand Down
8 changes: 8 additions & 0 deletions vm/tests/generators.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ def g2():
yield i
assert tuple(g2()) == (0,1,2,3,4)

doc="generator 3"
ok = False
try:
Comment thread
corona10 marked this conversation as resolved.
list(ax for x in range(10))
except NameError:
ok = True
assert ok, "NameError not raised"

doc="yield from"
def g3():
yield "potato"
Expand Down

Back | FazBrowse Home | New Git URL