1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-02-07 13:40:48 +00:00

utils/misc: fix to_identifier for unicode

string.translate() can fail when passed a unicode object; explicitly str()
it first to avoid this.
This commit is contained in:
Sergei Trofimov 2018-02-21 14:00:24 +00:00 committed by setrofim
parent 515095d9b2
commit 9e8f77b8f2

View File

@ -526,7 +526,7 @@ def to_identifier(text):
whitespace and punctuation and adding a prefix if starting with a digit""" whitespace and punctuation and adding a prefix if starting with a digit"""
if text[:1].isdigit(): if text[:1].isdigit():
text = '_' + text text = '_' + text
return re.sub('_+', '_', text.translate(TRANS_TABLE)) return re.sub('_+', '_', str(text).translate(TRANS_TABLE))
def unique(alist): def unique(alist):