clean up some code
authorStefan Behnel <stefan_ml@behnel.de>
Sat, 14 Sep 2013 06:33:35 +0000 (08:33 +0200)
committerStefan Behnel <stefan_ml@behnel.de>
Sat, 14 Sep 2013 06:33:35 +0000 (08:33 +0200)
Cython/Compiler/Code.py

index e58a3e8..074506d 100644 (file)
@@ -1093,13 +1093,9 @@ class GlobalState(object):
         self.py_constants.append(c)
         return c
 
-    def new_string_const_cname(self, bytes_value, intern=None):
+    def new_string_const_cname(self, bytes_value):
         # Create a new globally-unique nice name for a C string constant.
-        try:
-            value = bytes_value.decode('ASCII')
-        except UnicodeError:
-            return self.new_const_cname(value=bytes_value)
-
+        value = bytes_value.decode('ASCII', 'ignore')
         return self.new_const_cname(value=value)
 
     def new_int_const_cname(self, value, longness):
@@ -1114,7 +1110,7 @@ class GlobalState(object):
             value = value.decode('ASCII', 'ignore')
         value = replace_identifier('_', value)[:32].strip('_')
         c = self.const_cname_counters
-        c[value] = c.setdefault(value, 0) + 1
+        c[value] = c.get(value, 0) + 1
         if c[value] == 1:
             return "%s%s%s" % (Naming.const_prefix, prefix, value)
         else: