From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Anthony Liguori" <aliguori@us.ibm.com>,
"Stefan Hajnoczi" <stefanha@linux.vnet.ibm.com>,
"Erik Rull" <erik.rull@rdsoftware.de>,
"Andreas Faerber" <afaerber@suse.de>,
"Lluís Vilanova" <vilanova@ac.upc.edu>
Subject: [Qemu-devel] [PATCH v3 3/5] tracetool: avoid str.rpartition() Python 2.5 function
Date: Tue, 1 May 2012 16:40:57 +0100 [thread overview]
Message-ID: <1335886859-1028-4-git-send-email-stefanha@linux.vnet.ibm.com> (raw)
In-Reply-To: <1335886859-1028-1-git-send-email-stefanha@linux.vnet.ibm.com>
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 <stefanha@linux.vnet.ibm.com>
Reviewed-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
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
next prev parent reply other threads:[~2012-05-01 15:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-01 15:40 [Qemu-devel] [PATCH v3 0/5] tracetool: Python 2.4 compatibility fixes Stefan Hajnoczi
2012-05-01 15:40 ` [Qemu-devel] [PATCH v3 1/5] tracetool: use Python 2.4-compatible exception handling syntax Stefan Hajnoczi
2012-05-01 15:40 ` [Qemu-devel] [PATCH v3 2/5] tracetool: use Python 2.4-compatible __import__() arguments Stefan Hajnoczi
2012-05-01 15:40 ` Stefan Hajnoczi [this message]
2012-05-01 15:40 ` [Qemu-devel] [PATCH v3 4/5] tracetool: avoid pkgutil.iter_modules() Python 2.7 function Stefan Hajnoczi
2012-05-01 15:40 ` [Qemu-devel] [PATCH v3 5/5] configure: check for supported Python 2.x versions Stefan Hajnoczi
2012-05-01 16:00 ` Lluís Vilanova
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1335886859-1028-4-git-send-email-stefanha@linux.vnet.ibm.com \
--to=stefanha@linux.vnet.ibm.com \
--cc=afaerber@suse.de \
--cc=aliguori@us.ibm.com \
--cc=erik.rull@rdsoftware.de \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=vilanova@ac.upc.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).