Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
c8a2d308
Commit
c8a2d308
authored
9 years ago
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '0.22.x'
Conflicts: tests/run/generators.pyx
parents
5994c4e6
b339e287
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
5 deletions
+34
-5
Cython/Utility/Generator.c
Cython/Utility/Generator.c
+17
-5
tests/run/generators.pyx
tests/run/generators.pyx
+17
-0
No files found.
Cython/Utility/Generator.c
View file @
c8a2d308
...
@@ -271,6 +271,15 @@ PyObject *__Pyx_Generator_SendEx(__pyx_GeneratorObject *self, PyObject *value) {
...
@@ -271,6 +271,15 @@ PyObject *__Pyx_Generator_SendEx(__pyx_GeneratorObject *self, PyObject *value) {
return
retval
;
return
retval
;
}
}
static
CYTHON_INLINE
PyObject
*
__Pyx_Generator_MethodReturn
(
PyObject
*
retval
)
{
if
(
unlikely
(
!
retval
&&
!
PyErr_Occurred
()))
{
// method call must not terminate with NULL without setting an exception
PyErr_SetNone
(
PyExc_StopIteration
);
}
return
retval
;
}
static
CYTHON_INLINE
static
CYTHON_INLINE
PyObject
*
__Pyx_Generator_FinishDelegation
(
__pyx_GeneratorObject
*
gen
)
{
PyObject
*
__Pyx_Generator_FinishDelegation
(
__pyx_GeneratorObject
*
gen
)
{
PyObject
*
ret
;
PyObject
*
ret
;
...
@@ -306,6 +315,7 @@ static PyObject *__Pyx_Generator_Next(PyObject *self) {
...
@@ -306,6 +315,7 @@ static PyObject *__Pyx_Generator_Next(PyObject *self) {
}
}
static
PyObject
*
__Pyx_Generator_Send
(
PyObject
*
self
,
PyObject
*
value
)
{
static
PyObject
*
__Pyx_Generator_Send
(
PyObject
*
self
,
PyObject
*
value
)
{
PyObject
*
retval
;
__pyx_GeneratorObject
*
gen
=
(
__pyx_GeneratorObject
*
)
self
;
__pyx_GeneratorObject
*
gen
=
(
__pyx_GeneratorObject
*
)
self
;
PyObject
*
yf
=
gen
->
yieldfrom
;
PyObject
*
yf
=
gen
->
yieldfrom
;
if
(
unlikely
(
__Pyx_Generator_CheckRunning
(
gen
)))
if
(
unlikely
(
__Pyx_Generator_CheckRunning
(
gen
)))
...
@@ -328,9 +338,11 @@ static PyObject *__Pyx_Generator_Send(PyObject *self, PyObject *value) {
...
@@ -328,9 +338,11 @@ static PyObject *__Pyx_Generator_Send(PyObject *self, PyObject *value) {
if
(
likely
(
ret
))
{
if
(
likely
(
ret
))
{
return
ret
;
return
ret
;
}
}
return
__Pyx_Generator_FinishDelegation
(
gen
);
retval
=
__Pyx_Generator_FinishDelegation
(
gen
);
}
else
{
retval
=
__Pyx_Generator_SendEx
(
gen
,
value
);
}
}
return
__Pyx_Generator_
SendEx
(
gen
,
value
);
return
__Pyx_Generator_
MethodReturn
(
retval
);
}
}
// This helper function is used by gen_close and gen_throw to
// This helper function is used by gen_close and gen_throw to
...
@@ -424,7 +436,7 @@ static PyObject *__Pyx_Generator_Throw(PyObject *self, PyObject *args) {
...
@@ -424,7 +436,7 @@ static PyObject *__Pyx_Generator_Throw(PyObject *self, PyObject *args) {
Py_DECREF
(
yf
);
Py_DECREF
(
yf
);
__Pyx_Generator_Undelegate
(
gen
);
__Pyx_Generator_Undelegate
(
gen
);
if
(
err
<
0
)
if
(
err
<
0
)
return
__Pyx_Generator_
SendEx
(
gen
,
NULL
);
return
__Pyx_Generator_
MethodReturn
(
__Pyx_Generator_SendEx
(
gen
,
NULL
)
);
goto
throw_here
;
goto
throw_here
;
}
}
gen
->
is_running
=
1
;
gen
->
is_running
=
1
;
...
@@ -451,11 +463,11 @@ static PyObject *__Pyx_Generator_Throw(PyObject *self, PyObject *args) {
...
@@ -451,11 +463,11 @@ static PyObject *__Pyx_Generator_Throw(PyObject *self, PyObject *args) {
if
(
!
ret
)
{
if
(
!
ret
)
{
ret
=
__Pyx_Generator_FinishDelegation
(
gen
);
ret
=
__Pyx_Generator_FinishDelegation
(
gen
);
}
}
return
ret
;
return
__Pyx_Generator_MethodReturn
(
ret
)
;
}
}
throw_here:
throw_here:
__Pyx_Raise
(
typ
,
val
,
tb
,
NULL
);
__Pyx_Raise
(
typ
,
val
,
tb
,
NULL
);
return
__Pyx_Generator_
SendEx
(
gen
,
NULL
);
return
__Pyx_Generator_
MethodReturn
(
__Pyx_Generator_SendEx
(
gen
,
NULL
)
);
}
}
static
int
__Pyx_Generator_traverse
(
PyObject
*
self
,
visitproc
visit
,
void
*
arg
)
{
static
int
__Pyx_Generator_traverse
(
PyObject
*
self
,
visitproc
visit
,
void
*
arg
)
{
...
...
This diff is collapsed.
Click to expand it.
tests/run/generators.pyx
View file @
c8a2d308
...
@@ -329,12 +329,29 @@ def test_return_in_finally(a):
...
@@ -329,12 +329,29 @@ def test_return_in_finally(a):
>>> d['i_was_here']
>>> d['i_was_here']
True
True
>>> d = dict()
>>> obj = test_return_in_finally(d)
>>> next(obj)
1
>>> obj.send(2)
Traceback (most recent call last):
StopIteration
>>> d['i_was_here']
True
>>> obj = test_return_in_finally(None)
>>> obj = test_return_in_finally(None)
>>> next(obj)
>>> next(obj)
1
1
>>> next(obj)
>>> next(obj)
Traceback (most recent call last):
Traceback (most recent call last):
StopIteration
StopIteration
>>> obj = test_return_in_finally(None)
>>> next(obj)
1
>>> obj.send(2)
Traceback (most recent call last):
StopIteration
"""
"""
yield
1
yield
1
try
:
try
:
...
...
This diff is collapsed.
Click to expand it.
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