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
Gwenaël Samain
cython
Commits
695dc278
Commit
695dc278
authored
Sep 26, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ticket #742: 'self' in closure of extension type method crashes at runtime
parent
d2ef994b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
3 deletions
+102
-3
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+6
-3
tests/run/self_in_ext_type_closure.py
tests/run/self_in_ext_type_closure.py
+96
-0
No files found.
Cython/Compiler/Nodes.py
View file @
695dc278
...
...
@@ -2457,8 +2457,11 @@ class DefNode(FuncDefNode):
for
arg
in
self
.
args
:
if
not
arg
.
type
.
is_pyobject
:
done
=
arg
.
type
.
create_from_py_utility_code
(
env
)
if
not
done
:
pass
# will fail later
if
not
arg
.
type
.
create_from_py_utility_code
(
env
):
pass
# will fail later
elif
arg
.
is_self_arg
and
arg
.
entry
.
in_closure
:
# must store 'self' in the closure explicitly for extension types
self
.
generate_arg_assignment
(
arg
,
arg
.
hdr_cname
,
code
)
if
not
self
.
signature_has_generic_args
():
if
has_star_or_kw_args
:
...
...
@@ -2945,7 +2948,7 @@ class DefNode(FuncDefNode):
for
arg
in
self
.
args
:
if
arg
.
needs_conversion
:
self
.
generate_arg_conversion
(
arg
,
code
)
elif
arg
.
entry
.
in_closure
:
elif
not
arg
.
is_self_arg
and
arg
.
entry
.
in_closure
:
if
arg
.
type
.
is_pyobject
:
code
.
put_incref
(
arg
.
hdr_cname
,
py_object_type
)
code
.
putln
(
'%s = %s;'
%
(
arg
.
entry
.
cname
,
arg
.
hdr_cname
))
...
...
tests/run/self_in_ext_type_closure.py
0 → 100644
View file @
695dc278
# mode: run
# ticket: 742
import
cython
@
cython
.
cclass
class
ExtType
(
object
):
def
const1
(
self
):
return
1
def
ext_method0
(
self
):
"""
>>> x = ExtType()
>>> x.ext_method0()()
1
"""
def
func
():
return
self
.
const1
()
return
func
def
ext_method1
(
self
,
a
):
"""
>>> x = ExtType()
>>> x.ext_method1(2)()
(1, 2)
"""
def
func
():
return
self
.
const1
(),
a
return
func
def
ext_method1_def
(
self
,
a
=
2
):
"""
>>> x = ExtType()
>>> x.ext_method1_def()()
(1, 2)
>>> x.ext_method1_def(3)()
(1, 3)
"""
def
func
():
return
self
.
const1
(),
a
return
func
def
ext_method_args
(
self
,
*
args
):
"""
>>> x = ExtType()
>>> x.ext_method_args(2)()
(1, 2)
"""
def
func
():
return
self
.
const1
(),
args
[
0
]
return
func
def
ext_method_args_only
(
*
args
):
"""
>>> x = ExtType()
>>> x.ext_method_args_only(2)()
(1, 2)
"""
def
func
():
return
args
[
0
].
const1
(),
args
[
1
]
return
func
@
cython
.
cclass
class
GenType
(
object
):
def
const1
(
self
):
return
1
def
gen0
(
self
):
"""
>>> x = GenType()
>>> tuple(x.gen0())
(1, 2)
"""
yield
self
.
const1
()
yield
2
def
gen1
(
self
,
a
):
"""
>>> x = GenType()
>>> tuple(x.gen1(2))
(1, 2)
"""
yield
self
.
const1
()
yield
a
def
gen_default
(
self
,
a
=
2
):
"""
>>> x = GenType()
>>> tuple(x.gen_default())
(1, 2)
>>> tuple(x.gen_default(3))
(1, 3)
"""
yield
self
.
const1
()
yield
a
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