mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-22 19:40:58 +00:00
qapi: Fix cgen() for Python older than 2.7
A feature new in Python 2.7 crept into commit 77e703b: re.subn()'s fifth argument. Avoid that, use re.compile(). Backports commit 2752e5bedb26fa0c7291f810f9f534b688b2f1d2 from qemu
This commit is contained in:
parent
809b439562
commit
d59948f245
|
@ -942,7 +942,9 @@ def cgen(code, **kwds):
|
|||
raw = code % kwds
|
||||
if indent_level:
|
||||
indent = genindent(indent_level)
|
||||
raw = re.subn("^.", indent + r'\g<0>', raw, 0, re.MULTILINE)
|
||||
# re.subn() lacks flags support before Python 2.7, use re.compile()
|
||||
raw = re.subn(re.compile("^.", re.MULTILINE),
|
||||
indent + r'\g<0>', raw)
|
||||
raw = raw[0]
|
||||
return re.sub(re.escape(eatspace) + ' *', '', raw)
|
||||
|
||||
|
|
Loading…
Reference in a new issue