python: Use the unicode_escape codec

Python 2 had string_escape and unicode_escape codecs. Python 3 only has
the latter. These work the same as far as we're concerned, so let's use
the future-proof one.

However, the reste of the code expects unicode strings, so we need to
decode them again.

Signed-off-by: Mathieu Bridon <bochecha@daitauha.fr>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
This commit is contained in:
Mathieu Bridon 2018-06-07 12:26:20 +02:00 committed by Eric Engestrom
parent ad363913e6
commit 91939255a7
2 changed files with 2 additions and 2 deletions

View file

@ -65,7 +65,7 @@ class StringTable:
"""
fragments = [
'"%s\\0" /* %s */' % (
te[0].encode('string_escape'),
te[0].encode('unicode_escape').decode(),
', '.join(str(idx) for idx in sorted(te[2]))
)
for te in self.table

View file

@ -61,7 +61,7 @@ class StringTable:
"""
fragments = [
'"%s\\0" /* %s */' % (
te[0].encode('string_escape'),
te[0].encode('unicode_escape').decode(),
', '.join(str(idx) for idx in te[2])
)
for te in self.table