Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
aad3f44e
Commit
aad3f44e
authored
Jun 05, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #589 from kmod/generators
Slightly change generator StopIteration handling
parents
6f84f646
a16e8982
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
5 deletions
+20
-5
src/runtime/generator.cpp
src/runtime/generator.cpp
+4
-3
test/tests/generators.py
test/tests/generators.py
+16
-2
No files found.
src/runtime/generator.cpp
View file @
aad3f44e
...
@@ -124,7 +124,7 @@ static void generatorSendInternal(BoxedGenerator* self, Box* v) {
...
@@ -124,7 +124,7 @@ static void generatorSendInternal(BoxedGenerator* self, Box* v) {
// check if the generator already exited
// check if the generator already exited
if
(
self
->
entryExited
)
{
if
(
self
->
entryExited
)
{
freeGeneratorStack
(
self
);
freeGeneratorStack
(
self
);
r
eturn
;
r
aiseExcHelper
(
StopIteration
,
(
const
char
*
)
nullptr
)
;
}
}
self
->
returnValue
=
v
;
self
->
returnValue
=
v
;
...
@@ -189,9 +189,10 @@ Box* generatorSend(Box* s, Box* v) {
...
@@ -189,9 +189,10 @@ Box* generatorSend(Box* s, Box* v) {
// exc.
// exc.
assert
(
self
->
exception
.
type
==
NULL
||
self
->
exception
.
matches
(
StopIteration
));
assert
(
self
->
exception
.
type
==
NULL
||
self
->
exception
.
matches
(
StopIteration
));
ExcInfo
old_exc
=
self
->
exception
;
ExcInfo
old_exc
=
self
->
exception
;
self
->
exception
=
excInfoForRaise
(
StopIteration
,
None
,
None
);
// Clear the exception for GC purposes:
self
->
exception
=
ExcInfo
(
nullptr
,
nullptr
,
nullptr
);
if
(
old_exc
.
type
==
NULL
)
if
(
old_exc
.
type
==
NULL
)
old_exc
=
self
->
exception
;
raiseExcHelper
(
StopIteration
,
(
const
char
*
)
nullptr
)
;
raiseRaw
(
old_exc
);
raiseRaw
(
old_exc
);
}
}
...
...
test/tests/generators.py
View file @
aad3f44e
...
@@ -108,9 +108,23 @@ g10.next()
...
@@ -108,9 +108,23 @@ g10.next()
try
:
try
:
g10
.
next
()
g10
.
next
()
except
StopIteration
as
e
:
except
StopIteration
as
e
:
print
"C
o
ught exc1:"
,
type
(
e
),
e
print
"C
a
ught exc1:"
,
type
(
e
),
e
try
:
try
:
g10
.
next
()
g10
.
next
()
except
StopIteration
as
e
:
except
StopIteration
as
e
:
print
"C
o
ught exc2:"
,
type
(
e
),
e
print
"C
a
ught exc2:"
,
type
(
e
),
e
def
f
():
yield
1
/
0
g
=
f
()
try
:
g
.
next
()
except
Exception
as
e
:
print
type
(
e
),
e
# ZeroDivisionError
try
:
g
.
next
()
except
Exception
as
e
:
print
type
(
e
),
e
# StopIteration
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment