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
2c71d548
Commit
2c71d548
authored
Mar 30, 2012
by
scoder
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #106 from vitek/master
Regression fixes
parents
7ef9c72f
d099cfe2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
11 deletions
+77
-11
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+2
-4
Cython/Utility/Generator.c
Cython/Utility/Generator.c
+32
-7
tests/run/attribute_and_lambda.pyx
tests/run/attribute_and_lambda.pyx
+13
-0
tests/run/test_generator_frame_cycle.py
tests/run/test_generator_frame_cycle.py
+30
-0
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
2c71d548
...
...
@@ -1789,10 +1789,8 @@ class AnalyseExpressionsTransform(CythonTransform):
return
node
def
visit_AttributeNode
(
self
,
node
):
# Note: Expression analysis for attributes has already happened
# at this point (by recursive calls starting from FuncDefNode)
#print node.dump()
#return node
self
.
visitchildren
(
node
)
type
=
node
.
obj
.
type
if
type
.
is_extension_type
and
type
.
objstruct_cname
==
'PyArrayObject'
:
from
NumpySupport
import
numpy_transform_attribute_node
...
...
Cython/Utility/Generator.c
View file @
2c71d548
...
...
@@ -23,6 +23,7 @@ static CYTHON_INLINE PyObject* __Pyx_Generator_Yield_From(__pyx_GeneratorObject
//////////////////// Generator.proto ////////////////////
#define __Pyx_Generator_USED
#include <structmember.h>
#include <frameobject.h>
typedef
PyObject
*
(
*
__pyx_generator_body_t
)(
PyObject
*
,
PyObject
*
);
...
...
@@ -186,19 +187,43 @@ PyObject *__Pyx_Generator_SendEx(__pyx_GeneratorObject *self, PyObject *value) {
}
if
(
value
)
__Pyx_ExceptionSwap
(
&
self
->
exc_type
,
&
self
->
exc_value
,
&
self
->
exc_traceback
);
else
if
(
value
)
{
/* Generators always return to their most recent caller, not
* necessarily their creator. */
if
(
self
->
exc_traceback
)
{
PyThreadState
*
tstate
=
PyThreadState_GET
();
PyTracebackObject
*
tb
=
(
PyTracebackObject
*
)
self
->
exc_traceback
;
PyFrameObject
*
f
=
tb
->
tb_frame
;
Py_XINCREF
(
tstate
->
frame
);
assert
(
f
->
f_back
==
NULL
);
f
->
f_back
=
tstate
->
frame
;
}
__Pyx_ExceptionSwap
(
&
self
->
exc_type
,
&
self
->
exc_value
,
&
self
->
exc_traceback
);
}
else
{
__Pyx_Generator_ExceptionClear
(
self
);
}
self
->
is_running
=
1
;
retval
=
self
->
body
((
PyObject
*
)
self
,
value
);
self
->
is_running
=
0
;
if
(
retval
)
__Pyx_ExceptionSwap
(
&
self
->
exc_type
,
&
self
->
exc_value
,
&
self
->
exc_traceback
);
else
if
(
retval
)
{
__Pyx_ExceptionSwap
(
&
self
->
exc_type
,
&
self
->
exc_value
,
&
self
->
exc_traceback
);
/* Don't keep the reference to f_back any longer than necessary. It
* may keep a chain of frames alive or it could create a reference
* cycle. */
if
(
self
->
exc_traceback
)
{
PyTracebackObject
*
tb
=
(
PyTracebackObject
*
)
self
->
exc_traceback
;
PyFrameObject
*
f
=
tb
->
tb_frame
;
Py_CLEAR
(
f
->
f_back
);
}
}
else
{
__Pyx_Generator_ExceptionClear
(
self
);
}
return
retval
;
}
...
...
@@ -546,7 +571,7 @@ static PyTypeObject __pyx_GeneratorType_type = {
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
,
/* tp_flags*/
0
,
/*tp_doc*/
(
traverseproc
)
__Pyx_Generator_traverse
,
/*tp_traverse*/
(
inquiry
)
__Pyx_Generator_clear
,
/*tp_clear*/
0
,
/*tp_clear*/
0
,
/*tp_richcompare*/
offsetof
(
__pyx_GeneratorObject
,
gi_weakreflist
),
/* tp_weaklistoffse */
PyObject_SelfIter
,
/*tp_iter*/
...
...
tests/run/attribute_and_lambda.pyx
0 → 100644
View file @
2c71d548
# mode: run
# tags: lambda, attribute, regression
class
TestClass
(
object
):
bar
=
123
def
test_attribute_and_lambda
(
f
):
"""
>>> test_attribute_and_lambda(lambda _: TestClass())
123
"""
return
f
(
lambda
x
:
x
).
bar
tests/run/test_generator_frame_cycle.py
0 → 100644
View file @
2c71d548
# mode: run
# tags: generator
import
sys
def
_next
(
it
):
if
sys
.
version_info
[
0
]
>=
3
:
return
next
(
it
)
else
:
return
it
.
next
()
def
test_generator_frame_cycle
():
"""
>>> test_generator_frame_cycle()
("I'm done",)
"""
testit
=
[]
def
whoo
():
try
:
yield
except
:
yield
finally
:
testit
.
append
(
"I'm done"
)
g
=
whoo
()
_next
(
g
)
# Frame object cycle
eval
(
'g.throw(ValueError)'
,
{
'g'
:
g
})
del
g
return
tuple
(
testit
)
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