From: Stefan Behnel Date: Sat, 22 Jan 2011 16:10:30 +0000 (+0100) Subject: fix C name redefinition: names must be uniquified at the module scope, local scope... X-Git-Tag: 0.14.1rc2~3 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ab6291684786c2dbbde8d9e00127b66981afbc85;p=cython.git 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 --- 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