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
Kirill Smelkov
cython
Commits
ff9bf7c2
Commit
ff9bf7c2
authored
Jun 11, 2019
by
Josh Tobin
Committed by
Stefan Behnel
Jun 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mangle cname for closures in derived c class (GH-2990)
parent
a275799a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+4
-1
tests/run/closure_in_derived_class_T2967.pyx
tests/run/closure_in_derived_class_T2967.pyx
+18
-0
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
ff9bf7c2
...
...
@@ -2715,9 +2715,12 @@ class CreateClosureClasses(CythonTransform):
node
.
needs_outer_scope
=
True
return
# entry.cname can contain periods (eg. a derived C method of a class).
# We want to use the cname as part of a C struct name, so we replace
# periods with double underscores.
as_name
=
'%s_%s'
%
(
target_module_scope
.
next_id
(
Naming
.
closure_class_prefix
),
node
.
entry
.
cname
)
node
.
entry
.
cname
.
replace
(
'.'
,
'__'
)
)
entry
=
target_module_scope
.
declare_c_class
(
name
=
as_name
,
pos
=
node
.
pos
,
defining
=
True
,
...
...
tests/run/closure_in_derived_class_T2967.pyx
0 → 100644
View file @
ff9bf7c2
# mode: run
# tag: closures
# ticket: 2967
cdef
class
BaseClass
:
cdef
func
(
self
):
pass
cdef
class
ClosureInsideExtensionClass
(
BaseClass
):
"""
>>> y = ClosureInsideExtensionClass(42)
>>> y.test(42)
43
"""
cdef
func
(
self
):
a
=
1
return
(
lambda
x
:
x
+
a
)
def
test
(
self
,
b
):
return
self
.
func
()(
b
)
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