qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v3] qapi: provide a friendly string representation of QAPI cl


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v3] qapi: provide a friendly string representation of QAPI classes
Date: Wed, 18 Oct 2023 15:20:10 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.1

On 18/10/23 15:02, Daniel P. Berrangé wrote:
On Wed, Oct 18, 2023 at 02:37:45PM +0200, Markus Armbruster wrote:
Daniel P. Berrangé <berrange@redhat.com> writes:

If printing a QAPI schema object for debugging we get the classname and
a hex value for the instance:

   <qapi.schema.QAPISchemaEnumType object at 0x7f0ab4c2dad0>
   <qapi.schema.QAPISchemaObjectType object at 0x7f0ab4c2dd90>
   <qapi.schema.QAPISchemaArrayType object at 0x7f0ab4c2df90>

With this change we instead get the classname and the human friendly
name of the QAPI type instance:

   <QAPISchemaEnumType:CpuS390State at 0x7f0ab4c2dad0>
   <QAPISchemaObjectType:CpuInfoS390 at 0x7f0ab4c2dd90>
   <QAPISchemaArrayType:CpuInfoFastList at 0x7f0ab4c2df90>

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---


Mind if I swap things?  Like so:

     def __repr__(self):
         if self.name is None:
             return "<%s at 0x%x>" % (type(self).__name__, id(self))
         else:
             return "<%s:%s at 0x%x>" % (type(self).__name__,
                                         self.name, id(self))

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>


Sure, fine with me.

With regards,
Daniel



reply via email to

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