summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Armbruster2015-09-07 17:45:55 +0200
committerPeter Maydell2015-09-14 19:02:59 +0200
commit2752e5bedb26fa0c7291f810f9f534b688b2f1d2 (patch)
treee11d60006ff12ec471d11ff132f227a73fb4b41e
parentMerge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (diff)
downloadqemu-2752e5bedb26fa0c7291f810f9f534b688b2f1d2.tar.gz
qemu-2752e5bedb26fa0c7291f810f9f534b688b2f1d2.tar.xz
qemu-2752e5bedb26fa0c7291f810f9f534b688b2f1d2.zip
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(). Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Tested-by: Laurent Desnogues <laurent.desnogues@gmail.com> Message-id: 1441640755-23902-1-git-send-email-armbru@redhat.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--scripts/qapi.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 817d824bea..88fa073184 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -944,7 +944,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)