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

Re: [PATCH] tools/libxl: Make gentypes.py compatible with older Python


  • To: Jason Andryuk <jason.andryuk@xxxxxxx>, "jbeulich@xxxxxxxx" <jbeulich@xxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Tue, 21 Oct 2025 17:00:04 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PbIGtqr9eh8EqJk1Tm5rtipz030C7YccW48lvbw4m9w=; b=PwvJ2Uh+nzCaQgP0lzs1xP4a8pOc0wwzcKtWytCHE9xOyfhBH6WQJbaU2IVZi5g0KTQt9TrFapXEbqsc95KLSs8mInHGJbj5RzpltNAGTft2Y5Beeq0/28woTm22p2edheWBiGiEywDx1xKoXdi+IFZgKvAY3OVvws4382ehtsHJf8HoYTw3ecoeOtXAjsWhpZU6qqPvQ3/KR4+C911mRdWd8h41ih1Zj3nueyLUpLcLs9rc1kgN/w6iVU1+vAkD5sNo78EF7e822DUcFAxRxxg/5bJaERw+ouj/39ImJpDVbUHJ2DsSs5iAXz1tD8kPJNELRmWBwTIzNB6ss140+w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Pp06OFXHyIi4P7rCsZvQvtqgdur8lyMN3wDvrnRTZv2WOa2wta1RJJ29cuEKIR0fghA89Z1yi42qWQbXM/IuM4srNrxxAN//7Fd4LXXvMXh+jzreF+rkBCQv1qm9xxasAQ3nkGhS75Iu8U6vrmMexrlhtNv6YDihhLJLHvHPDzMrOXafdbP4IA635Pgjxn3avSFjKH81Uy2/gqs5cv/4k8349eCfxpamyCYxGeLjYWbkHegGqZ2DGHNtgrvW+nP2KruPBUWM8gGhMlM6Xve45zoPa5nZKM6eq5WSdq3dRgKTS/wHFZazrqtIbt1YkfPiTBmYR5ASzdGEMW2ZcMtcAw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Andrew Cooper <andrew.cooper@xxxxxxxxxx>, "anthony.perard@xxxxxxxxxx" <anthony.perard@xxxxxxxxxx>, "jgross@xxxxxxxx" <jgross@xxxxxxxx>, "oleksii.kurochko@xxxxxxxxx" <oleksii.kurochko@xxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 21 Oct 2025 16:00:33 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 17/10/2025 3:06 am, Jason Andryuk wrote:
> removeprefix is only added in Python 3.9.
>
> Instead of the prefix removal, switch to passing in a "depth" parameter,
> and incrementing it for each level.
>
> There is a slight change in the generated _libxl_types.c.  instances of
> KeyedUnion increment depth without outputing any code.  The net result
> is some cases where jso_sub_1 is followed by jso_sub_3.  As an example:
>
> _libxl_types.c
> _libxl_types.c
> @@ -5535,12 +5535,12 @@
>                  if (!jso_sub_1)
>                      goto out;
>                  if (!libxl__string_is_default(&p->u.pty.path)) {
> -                    json_object *jso_sub_2 = NULL;
> -                    rc = libxl__string_gen_jso(&jso_sub_2, p->u.pty.path);
> +                    json_object *jso_sub_3 = NULL;
> +                    rc = libxl__string_gen_jso(&jso_sub_3, p->u.pty.path);
>                      if (rc)
>                          goto out;
> -                    if (json_object_object_add(jso_sub_1, "path", 
> jso_sub_2)) {
> -                        json_object_put(jso_sub_2);
> +                    if (json_object_object_add(jso_sub_1, "path", 
> jso_sub_3)) {
> +                        json_object_put(jso_sub_3);
>                          goto out;
>                      }
>                  }
>
> Signed-off-by: Jason Andryuk <jason.andryuk@xxxxxxx>

Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

Personally, I think this is the nicest of the options posted.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.