From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:35961) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPFCY-0003Qk-9I for qemu-devel@nongnu.org; Tue, 01 May 2012 11:41:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SPFCW-000492-4h for qemu-devel@nongnu.org; Tue, 01 May 2012 11:41:17 -0400 Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:35533) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPFCV-00047X-Rv for qemu-devel@nongnu.org; Tue, 01 May 2012 11:41:16 -0400 Received: from /spool/local by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 1 May 2012 16:41:12 +0100 Received: from d06av09.portsmouth.uk.ibm.com (d06av09.portsmouth.uk.ibm.com [9.149.37.250]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q41Ff8BB2789472 for ; Tue, 1 May 2012 16:41:08 +0100 Received: from d06av09.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q41Ff8dT005172 for ; Tue, 1 May 2012 09:41:08 -0600 From: Stefan Hajnoczi Date: Tue, 1 May 2012 16:40:57 +0100 Message-Id: <1335886859-1028-4-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1335886859-1028-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1335886859-1028-1-git-send-email-stefanha@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH v3 3/5] tracetool: avoid str.rpartition() Python 2.5 function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Anthony Liguori , Stefan Hajnoczi , Erik Rull , Andreas Faerber , =?UTF-8?q?Llu=C3=ADs=20Vilanova?= The str.rpartition() function is related to str.split() and is used for splitting strings. It was introduced in Python 2.5 and therefore cannot be used in tracetool as Python 2.4 compatibility is required. Replace the code using str.rsplit(). Signed-off-by: Stefan Hajnoczi Reviewed-by: LluĂ­s Vilanova --- scripts/tracetool/__init__.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py index 49858c9..175df08 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -64,14 +64,17 @@ class Arguments: res = [] for arg in arg_str.split(","): arg = arg.strip() - parts = arg.split() - head, sep, tail = parts[-1].rpartition("*") - parts = parts[:-1] - if tail == "void": - assert len(parts) == 0 and sep == "" + if arg == 'void': continue - arg_type = " ".join(parts + [ " ".join([head, sep]).strip() ]).strip() - res.append((arg_type, tail)) + + if '*' in arg: + arg_type, identifier = arg.rsplit('*', 1) + arg_type += '*' + identifier = identifier.strip() + else: + arg_type, identifier = arg.rsplit(None, 1) + + res.append((arg_type, identifier)) return Arguments(res) def __iter__(self): -- 1.7.10