sb: Convert any unicode keys to strings

Closes #3313
This commit is contained in:
Chris Johns 2018-02-23 13:03:11 +11:00
parent 4671017f41
commit 883dfa53a3

View File

@ -150,7 +150,7 @@ class macros:
def __setitem__(self, key, value):
key = self._unicode_to_str(key)
if type(key) is not str:
raise TypeError('bad key type (want str): %s' % (type(key)))
raise TypeError('bad key type (want str): %s (%s)' % (type(key), key))
if type(value) is not tuple:
value = self._unicode_to_str(value)
if type(value) is str:
@ -396,6 +396,7 @@ class macros:
(path.host(self.expand(name))))
def get(self, key, globals = True, maps = None):
key = self._unicode_to_str(key)
if type(key) is not str:
raise TypeError('bad key type: %s' % (type(key)))
key = self.key_filter(key)
@ -435,11 +436,10 @@ class macros:
return self.get_attribute(key) == 'override'
def define(self, key, value = '1'):
if type(key) is not str:
raise TypeError('bad key type: %s' % (type(key)))
self.__setitem__(key, ('none', 'none', value))
def undefine(self, key):
key = self._unicode_to_str(key)
if type(key) is not str:
raise TypeError('bad key type: %s' % (type(key)))
key = self.key_filter(key)