qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] Remove Python 2.5 syntax from scripts/qapi-visit.py


From: Charlie Shepherd
Subject: [Qemu-devel] [PATCH] Remove Python 2.5 syntax from scripts/qapi-visit.py
Date: Thu, 29 Aug 2013 11:02:07 +0100
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8

On 29/08/2013 10:57, Charlie Shepherd wrote:

default_x86_64_rhel5:
http://buildbot.b1-systems.de/qemu/builders/default_x86_64_rhel5/builds/684/steps/compile/logs/stdio
    File 
"/home/buildbot/slave-public/default_x86_64_rhel5/build/scripts/qapi-visit.py", 
line 23
      full_name = name if not fn_prefix else "%s_%s" % (name, fn_prefix)
                        ^
SyntaxError: invalid syntax
make: *** [qapi-visit.h] Error 1
This syntax was introduced in Python 2.5, patch to follow to convert
this to valid Python 2.4 syntax.

The syntax `var = a if b else c` was added in Python 2.5, but QEMU has a

minimum Python version of 2.4, which chokes on this syntax. This patch

converts the new syntax to Python 2.4 compatible syntax.

---

 scripts/qapi-visit.py |   12 +++++++++---

 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py

index 597cca4..5d04438 100644

--- a/scripts/qapi-visit.py

+++ b/scripts/qapi-visit.py

@@ -20,7 +20,10 @@ import errno

 def generate_visit_struct_fields(name, field_prefix, fn_prefix, members):

     substructs = []

     ret = ''

-    full_name = name if not fn_prefix else "%s_%s" % (name, fn_prefix)

+    if not fn_prefix:

+        full_name = name

+    else:

+        full_name = "%s_%s" % (name, fn_prefix)

     for argname, argentry, optional, structured in parse_args(members):

         if structured:

@@ -84,7 +87,10 @@ if (!error_is_set(errp)) {

 ''')

     push_indent()

-    full_name = name if not field_prefix else "%s_%s" % (field_prefix, name)

+    if not fn_prefix:

+        full_name = name

+    else:

+        full_name = "%s_%s" % (name, fn_prefix)

     if len(field_prefix):

         ret += mcgen('''

@@ -270,7 +276,7 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const 
char *name, Error **

         if (!err) {

             switch ((*obj)->kind) {

 ''',

-                 name=name, type="type" if not discriminator else 
discriminator)

+                 name=name, type=(discriminator or "type"))

     for key in members:

         if not discriminator:

--

1.7.9.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]