Commit 39e5e254 authored by Stefan Behnel's avatar Stefan Behnel

clean up some code

parent e8b54dec
...@@ -1093,13 +1093,9 @@ class GlobalState(object): ...@@ -1093,13 +1093,9 @@ class GlobalState(object):
self.py_constants.append(c) self.py_constants.append(c)
return 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. # Create a new globally-unique nice name for a C string constant.
try: value = bytes_value.decode('ASCII', 'ignore')
value = bytes_value.decode('ASCII')
except UnicodeError:
return self.new_const_cname(value=bytes_value)
return self.new_const_cname(value=value) return self.new_const_cname(value=value)
def new_int_const_cname(self, value, longness): def new_int_const_cname(self, value, longness):
...@@ -1114,7 +1110,7 @@ class GlobalState(object): ...@@ -1114,7 +1110,7 @@ class GlobalState(object):
value = value.decode('ASCII', 'ignore') value = value.decode('ASCII', 'ignore')
value = replace_identifier('_', value)[:32].strip('_') value = replace_identifier('_', value)[:32].strip('_')
c = self.const_cname_counters c = self.const_cname_counters
c[value] = c.setdefault(value, 0) + 1 c[value] = c.get(value, 0) + 1
if c[value] == 1: if c[value] == 1:
return "%s%s%s" % (Naming.const_prefix, prefix, value) return "%s%s%s" % (Naming.const_prefix, prefix, value)
else: else:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment