summaryrefslogtreecommitdiff
path: root/Cython/Compiler/ParseTreeTransforms.py
diff options
context:
space:
mode:
authorJosh Tobin <tobinrj@tcd.ie>2019-06-11 15:08:59 -0400
committerStefan Behnel <stefan_ml@behnel.de>2019-06-11 21:09:58 +0200
commitff9bf7c2b822d37cfbb53383abd4bf6de54e61b7 (patch)
treee1f11f9977b1708b4ee890855f0bfeb90cb96f7f /Cython/Compiler/ParseTreeTransforms.py
parenta275799a872651864a015937a6641901ecca2257 (diff)
downloadcython-ff9bf7c2b822d37cfbb53383abd4bf6de54e61b7.tar.gz
Mangle cname for closures in derived c class (GH-2990)
Diffstat (limited to 'Cython/Compiler/ParseTreeTransforms.py')
-rw-r--r--Cython/Compiler/ParseTreeTransforms.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Cython/Compiler/ParseTreeTransforms.py b/Cython/Compiler/ParseTreeTransforms.py
index 4ff717b1d..5ba64b467 100644
--- a/Cython/Compiler/ParseTreeTransforms.py
+++ b/Cython/Compiler/ParseTreeTransforms.py
@@ -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,