[libvirt] [PATCH] Fix syntax error on Python 3.7

From 0d3b7cc9ba787a139ecbe6dac490b1f5bb021b7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz> Date: Wed, 27 Jun 2018 13:00:28 +0200 Subject: [PATCH] Fix syntax error on Python 3.7 async is a keyword now. `asyncio import ensure_future` works on Python 3.4 to 3.7 `from asyncio import async as ensure_future` is not needed. --- libvirtaio.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libvirtaio.py b/libvirtaio.py index 1c432dd..b100a5f 100644 --- a/libvirtaio.py +++ b/libvirtaio.py @@ -43,10 +43,7 @@ import warnings import libvirt -try: - from asyncio import ensure_future -except ImportError: - from asyncio import async as ensure_future +from asyncio import ensure_future class Callback(object): -- 2.17.0

On Wed, Jun 27, 2018 at 01:03:03PM +0200, Miro Hrončok wrote:
From 0d3b7cc9ba787a139ecbe6dac490b1f5bb021b7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz> Date: Wed, 27 Jun 2018 13:00:28 +0200 Subject: [PATCH] Fix syntax error on Python 3.7
async is a keyword now.
`asyncio import ensure_future` works on Python 3.4 to 3.7
`from asyncio import async as ensure_future` is not needed. --- libvirtaio.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
Thanks for the patch, but as noted in this review [1] using only 'ensure_future' is not good enough. Pavel [1] <https://www.redhat.com/archives/libvir-list/2018-June/msg01700.html>

On 27.6.2018 13:47, Pavel Hrdina wrote:
On Wed, Jun 27, 2018 at 01:03:03PM +0200, Miro Hrončok wrote:
From 0d3b7cc9ba787a139ecbe6dac490b1f5bb021b7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz> Date: Wed, 27 Jun 2018 13:00:28 +0200 Subject: [PATCH] Fix syntax error on Python 3.7
async is a keyword now.
`asyncio import ensure_future` works on Python 3.4 to 3.7
`from asyncio import async as ensure_future` is not needed. --- libvirtaio.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
Thanks for the patch, but as noted in this review [1] using only 'ensure_future' is not good enough.
Pavel
[1] <https://www.redhat.com/archives/libvir-list/2018-June/msg01700.html>
In that case you need to get async dynamically: From 70e4ab8cc02019487b9740812d68fd9d9d021192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz> Date: Wed, 27 Jun 2018 13:00:28 +0200 Subject: [PATCH] Fix syntax error on Python 3.7 async is a keyword now. `asyncio import ensure_future` works on Python 3.4.4 to 3.7. `from asyncio import async as ensure_future` is needed on Debian with Python 3.4.2, but we cannot type that, so we use getattr instead. --- libvirtaio.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libvirtaio.py b/libvirtaio.py index 1c432dd..45fa0c5 100644 --- a/libvirtaio.py +++ b/libvirtaio.py @@ -46,7 +46,10 @@ import libvirt try: from asyncio import ensure_future except ImportError: - from asyncio import async as ensure_future + # debina has python 3.4.2 without the above + # we cannot from asyncio import async, because of python 3.7+ + import asyncio + ensure_future = getattr(asyncio, 'async') class Callback(object): -- 2.17.0 -- Miro Hrončok -- Phone: +420777974800 IRC: mhroncok

On 27.6.2018 13:54, Miro Hrončok wrote:
On 27.6.2018 13:47, Pavel Hrdina wrote:
On Wed, Jun 27, 2018 at 01:03:03PM +0200, Miro Hrončok wrote:
From 0d3b7cc9ba787a139ecbe6dac490b1f5bb021b7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz> Date: Wed, 27 Jun 2018 13:00:28 +0200 Subject: [PATCH] Fix syntax error on Python 3.7
async is a keyword now.
`asyncio import ensure_future` works on Python 3.4 to 3.7
`from asyncio import async as ensure_future` is not needed. --- libvirtaio.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
Thanks for the patch, but as noted in this review [1] using only 'ensure_future' is not good enough.
Pavel
[1] <https://www.redhat.com/archives/libvir-list/2018-June/msg01700.html>
In that case you need to get async dynamically...
Sorry, I wasn't on the list before and I missed the fact that this is already being handled. Ignore me. -- Miro Hrončok -- Phone: +420777974800 IRC: mhroncok
participants (2)
-
Miro Hrončok
-
Pavel Hrdina