From d59948f245cf247c2ee23ef1a195485f5ac55fb7 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 19 Feb 2018 16:34:14 -0500 Subject: [PATCH] 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 --- qemu/scripts/qapi.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qemu/scripts/qapi.py b/qemu/scripts/qapi.py index c864070a..91ce0489 100644 --- a/qemu/scripts/qapi.py +++ b/qemu/scripts/qapi.py @@ -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)