From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYycL-0006Mq-QO for qemu-devel@nongnu.org; Mon, 07 Sep 2015 11:46:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYycI-000824-Eg for qemu-devel@nongnu.org; Mon, 07 Sep 2015 11:46:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45637) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYycI-00081Z-9n for qemu-devel@nongnu.org; Mon, 07 Sep 2015 11:45:58 -0400 From: Markus Armbruster Date: Mon, 7 Sep 2015 17:45:55 +0200 Message-Id: <1441640755-23902-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH] qapi: Fix cgen() for Python older than 2.7 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: laurent.desnogues@gmail.com, mdroth@linux.vnet.ibm.com 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 Signed-off-by: Markus Armbruster --- scripts/qapi.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index 817d824..88fa073 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) -- 2.4.3