From nobody Sun Feb 8 09:05:24 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1529951808162326.8398125815138; Mon, 25 Jun 2018 11:36:48 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9BB584E90C; Mon, 25 Jun 2018 18:36:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AC9BD77E83; Mon, 25 Jun 2018 18:36:42 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id EAB673FCC0; Mon, 25 Jun 2018 18:36:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5PIZXxZ008900 for ; Mon, 25 Jun 2018 14:35:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5436C59870; Mon, 25 Jun 2018 18:35:33 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-117-39.phx2.redhat.com [10.3.117.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id DBD74171D9; Mon, 25 Jun 2018 18:35:30 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 25 Jun 2018 14:35:28 -0400 Message-Id: <1628bcfd04594298769425871cc1d5b515aefea1.1529950820.git.crobinso@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH python] libvirtaio: Fix compat with python 3.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 25 Jun 2018 18:36:46 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In python 3.7, async is now a keyword, so this throws a syntax error: File "/usr/lib64/python3.7/site-packages/libvirtaio.py", line 49 from asyncio import async as ensure_future ^ SyntaxError: invalid syntax Switch to getattr trickery to accomplish the same goal Signed-off-by: Cole Robinson Reviewed-by: Pavel Hrdina --- libvirtaio.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) If we don't care about python3 < 3.4.4 compat, we can just do from asyncio import ensure_future diff --git a/libvirtaio.py b/libvirtaio.py index 1c432dd..9d517e6 100644 --- a/libvirtaio.py +++ b/libvirtaio.py @@ -43,10 +43,12 @@ import warnings =20 import libvirt =20 -try: - from asyncio import ensure_future -except ImportError: - from asyncio import async as ensure_future +# python < 3.4.4: we want 'async' +# python >=3D 3.4.4 < 3.7, we want 'ensure_future' +# python >=3D 3.7, 'async' is a reserved keyword, so we can't import it +ensure_future =3D getattr(asyncio, "ensure_future", None) +if not ensure_future: + ensure_future =3D getattr(asyncio, "async") =20 =20 class Callback(object): --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list