From ab6291684786c2dbbde8d9e00127b66981afbc85 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sat, 22 Jan 2011 17:10:30 +0100 Subject: [PATCH] fix C name redefinition: names must be uniquified at the module scope, local scope is not enough as it may not have a unique name itself --- Cython/Compiler/Symtab.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py index 536cb72e..74a80eb8 100644 --- a/Cython/Compiler/Symtab.py +++ b/Cython/Compiler/Symtab.py @@ -306,13 +306,17 @@ class Scope(object): #return self.parent_scope.mangle(prefix, self.name) def next_id(self, name=None): - # Return a cname fragment that is unique for this scope. + # Return a cname fragment that is unique for this module + counters = self.global_scope().id_counters try: - count = self.id_counters[name] + 1 + count = counters[name] + 1 except KeyError: count = 0 - self.id_counters[name] = count + counters[name] = count if name: + if not count: + # unique names don't need a suffix, reoccurrences will get one + return name return '%s%d' % (name, count) else: return '%d' % count -- 2.26.2