mirror of
https://github.com/OlafvdSpek/ctemplate.git
synced 2025-10-05 19:16:54 +08:00
Switch Python scripts to Python 3
The scripts had already the majority of the work needed for Python 3, and Python 2 is EOL since Jan 1st 2020, so just the scripts to Python 3. The last change required is to fix the repr() on chars, due to the text vs data changes in Python 3: repr() prints more Unicode representations now, breaking the C output (e.g. \r now is lterally printed as such, removing all the content in the line before that). As fix, use the workaround proposed in PEP-3138 [1]. This fixes the generate_fsm_test_sh test. [1] https://www.python.org/dev/peps/pep-3138/#id10
This commit is contained in:
parent
c6002f3f52
commit
ee11ba100a
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (c) 2008, Google Inc.
|
||||
# All rights reserved.
|
||||
|
@ -282,7 +282,8 @@ class FSMGenerateC(FSMGenerateAbstract):
|
|||
for state in self._config.states:
|
||||
transition_row = []
|
||||
for c in range(0, 255):
|
||||
transition_row.append(' /* %06s */ %s' % (repr(chr(c)),
|
||||
ch_repr = str(repr(chr(c)).encode("ASCII", "backslashreplace"), "ASCII")
|
||||
transition_row.append(' /* %06s */ %s' % (ch_repr,
|
||||
state_table[state][c]))
|
||||
|
||||
out.append(self._CreateStructList('%stransition_row_%s' %
|
||||
|
|
Loading…
Reference in New Issue
Block a user