[PATCH 01/19] qapi/schema: fix QAPISchemaEntity.__repr__()

John Snow posted 19 patches 1 year ago
There is a newer version of this series
[PATCH 01/19] qapi/schema: fix QAPISchemaEntity.__repr__()
Posted by John Snow 1 year ago
This needs parentheses to work how you want it to:

>>> "%s-%s-%s" % 'a', 'b', 'c'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: not enough arguments for format string

>>> "%s-%s-%s" % ('a', 'b', 'c')
'a-b-c'

Signed-off-by: John Snow <jsnow@redhat.com>
---
 scripts/qapi/schema.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
index d739e558e9e..c79747b2a15 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -76,7 +76,7 @@ def __init__(self, name: str, info, doc, ifcond=None, features=None):
     def __repr__(self):
         if self.name is None:
             return "<%s at 0x%x>" % (type(self).__name__, id(self))
-        return "<%s:%s at 0x%x>" % type(self).__name__, self.name, id(self)
+        return "<%s:%s at 0x%x>" % (type(self).__name__, self.name, id(self))
 
     def c_name(self):
         return c_name(self.name)
-- 
2.41.0
Re: [PATCH 01/19] qapi/schema: fix QAPISchemaEntity.__repr__()
Posted by Philippe Mathieu-Daudé 1 year ago
On 16/11/23 02:43, John Snow wrote:
> This needs parentheses to work how you want it to:
> 
>>>> "%s-%s-%s" % 'a', 'b', 'c'
> Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
> TypeError: not enough arguments for format string
> 
>>>> "%s-%s-%s" % ('a', 'b', 'c')
> 'a-b-c'
> 
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>   scripts/qapi/schema.py | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
> index d739e558e9e..c79747b2a15 100644
> --- a/scripts/qapi/schema.py
> +++ b/scripts/qapi/schema.py
> @@ -76,7 +76,7 @@ def __init__(self, name: str, info, doc, ifcond=None, features=None):
>       def __repr__(self):
>           if self.name is None:
>               return "<%s at 0x%x>" % (type(self).__name__, id(self))
> -        return "<%s:%s at 0x%x>" % type(self).__name__, self.name, id(self)
> +        return "<%s:%s at 0x%x>" % (type(self).__name__, self.name, id(self))

This is commit 6d133eef98 ("qapi: Fix QAPISchemaEntity.__repr__()").