Permalink
Browse files

Fix bug #252, mangle illegal optional c argument names.

  • Loading branch information...
1 parent f3fd7f9 commit 2c3e76e2e821dd18b670bd0f0b6a3533848d4768 @robertwb robertwb committed Nov 5, 2009
@@ -2572,7 +2572,7 @@ def generate_result_code(self, code):
for formal_arg, actual_arg in args[expected_nargs:actual_nargs]:
code.putln("%s.%s = %s;" % (
self.opt_arg_struct,
- formal_arg.name,
+ func_type.opt_arg_cname(formal_arg.name),
actual_arg.result_as(formal_arg.type)))
exc_checks = []
if self.type.is_pyobject:
View
@@ -1473,13 +1473,11 @@ def generate_argument_parsing_code(self, env, code):
code.putln('if (%s) {' % Naming.optional_args_cname)
for arg in self.args:
if arg.default:
- # FIXME: simple name prefixing doesn't work when
- # argument name mangling is in place
code.putln('if (%s->%sn > %s) {' % (Naming.optional_args_cname, Naming.pyrex_prefix, i))
declarator = arg.declarator
while not hasattr(declarator, 'name'):
declarator = declarator.base
- code.putln('%s = %s->%s;' % (arg.cname, Naming.optional_args_cname, declarator.name))
+ code.putln('%s = %s->%s;' % (arg.cname, Naming.optional_args_cname, self.type.opt_arg_cname(declarator.name)))
i += 1
for _ in range(self.type.optional_arg_count):
code.putln('}')
@@ -1535,6 +1535,9 @@ def signature_string(self):
def signature_cast_string(self):
s = self.declaration_code("(*)", with_calling_convention=False)
return '(%s)' % s
+
+ def opt_arg_cname(self, arg_name):
+ return self.op_arg_struct.base_type.scope.lookup(arg_name).cname
class CFuncTypeArg(object):
View
@@ -5,5 +5,4 @@ methodmangling_T5
class_attribute_init_values_T18
numpy_ValueError_T172
unsignedbehaviour_T184
-bad_c_struct_T252
missing_baseclass_in_predecl_T262
@@ -1,10 +1,10 @@
cdef cf(default=None):
return default
-cpdef cpf(default=None):
+cpdef cpf(default=100):
"""
>>> cpf()
- None
+ 100
>>> cpf(1)
1
>>> cpf(default=2)
@@ -13,10 +13,10 @@ cpdef cpf(default=None):
default = cf(default)
return default
-def pf(default=None):
+def pf(default=100):
"""
>>> pf()
- None
+ 100
>>> pf(1)
1
>>> pf(default=2)

0 comments on commit 2c3e76e

Please sign in to comment.