15
0

Accepting request 1060676 from devel:languages:python

- Add py311.patch to make the code compatible with python 3.11

OBS-URL: https://build.opensuse.org/request/show/1060676
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-aioeventlet?expand=0&rev=5
This commit is contained in:
2023-01-24 18:44:05 +00:00
committed by Git OBS Bridge
3 changed files with 139 additions and 5 deletions

127
py311.patch Normal file
View File

@@ -0,0 +1,127 @@
Index: aioeventlet-0.5.1/tests/test_eventlet.py
===================================================================
--- aioeventlet-0.5.1.orig/tests/test_eventlet.py
+++ aioeventlet-0.5.1/tests/test_eventlet.py
@@ -19,72 +19,78 @@ try:
import asyncio
exec('''if 1:
- @asyncio.coroutine
- def coro_wrap_greenthread():
+ async def coro_wrap_greenthread():
result = []
gt = eventlet.spawn(eventlet_slow_append, result, 1, 0.020)
- value = yield from aioeventlet.wrap_greenthread(gt)
+ for i in aioeventlet.wrap_greenthread(gt):
+ value = yield i
result.append(value)
gt = eventlet.spawn(eventlet_slow_append, result, 2, 0.010)
- value = yield from aioeventlet.wrap_greenthread(gt)
+ for i in aioeventlet.wrap_greenthread(gt):
+ value = yield i
result.append(value)
gt = eventlet.spawn(eventlet_slow_error)
try:
- yield from aioeventlet.wrap_greenthread(gt)
+ for i in aioeventlet.wrap_greenthread(gt):
+ yield i
except ValueError as exc:
result.append(str(exc))
result.append(4)
- return result
+ yield result
+ return
- @asyncio.coroutine
- def coro_slow_append(result, value, delay=SHORT_SLEEP):
- yield from asyncio.sleep(delay)
+ async def coro_slow_append(result, value, delay=SHORT_SLEEP):
+ for i in asyncio.sleep(delay):
+ yield i
result.append(value)
- return value * 10
+ yield value * 10
+ return
- @asyncio.coroutine
- def coro_slow_error():
- yield from asyncio.sleep(0.001)
+ async def coro_slow_error():
+ for i in asyncio.sleep(0.001):
+ yield i
raise ValueError("error")
''')
except ImportError:
import trollius as asyncio
from trollius import From, Return
- @asyncio.coroutine
- def coro_wrap_greenthread():
+ async def coro_wrap_greenthread():
result = []
gt = eventlet.spawn(eventlet_slow_append, result, 1, 0.020)
- value = yield From(aioeventlet.wrap_greenthread(gt))
+ for i in From(aioeventlet.wrap_greenthread(gt)):
+ value = yield i
result.append(value)
gt = eventlet.spawn(eventlet_slow_append, result, 2, 0.010)
- value = yield From(aioeventlet.wrap_greenthread(gt))
+ for i in From(aioeventlet.wrap_greenthread(gt)):
+ value = yield i
result.append(value)
gt = eventlet.spawn(eventlet_slow_error)
try:
- yield From(aioeventlet.wrap_greenthread(gt))
+ for i in From(aioeventlet.wrap_greenthread(gt)):
+ yield i
except ValueError as exc:
result.append(str(exc))
result.append(4)
raise Return(result)
- @asyncio.coroutine
- def coro_slow_append(result, value, delay=SHORT_SLEEP):
- yield From(asyncio.sleep(delay))
+ async def coro_slow_append(result, value, delay=SHORT_SLEEP):
+ for i in From(asyncio.sleep(delay)):
+ yield i
result.append(value)
raise Return(value * 10)
- @asyncio.coroutine
- def coro_slow_error():
- yield From(asyncio.sleep(0.001))
+ async def coro_slow_error():
+ for i in From(asyncio.sleep(0.001)):
+ yield i
raise ValueError("error")
@@ -223,8 +229,7 @@ class LinkFutureTests(tests.TestCase):
def func(obj):
return aioeventlet.yield_future(obj)
- @asyncio.coroutine
- def coro_func():
+ async def coro_func():
print("do something")
def regular_func():
@@ -315,8 +320,7 @@ class WrapGreenthreadTests(tests.TestCas
pass
self.assertRaises(TypeError, aioeventlet.wrap_greenthread, func)
- @asyncio.coroutine
- def coro_func():
+ async def coro_func():
pass
coro_obj = coro_func()
self.addCleanup(coro_obj.close)

View File

@@ -1,3 +1,8 @@
-------------------------------------------------------------------
Tue Jan 24 16:38:55 UTC 2023 - Daniel Garcia <daniel.garcia@suse.com>
- Add py311.patch to make the code compatible with python 3.11
-------------------------------------------------------------------
Wed Aug 19 10:34:12 UTC 2020 - John Vandenberg <jayvdb@gmail.com>

View File

@@ -1,7 +1,7 @@
#
# spec file for package python-aioeventlet
#
# Copyright (c) 2020 SUSE LLC
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,6 @@
# versioning fun
%define intver 0.5.1
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-aioeventlet
Version: 0.5.2
Release: 0
@@ -28,6 +27,8 @@ URL: https://pypi.org/project/aioeventlet/
Source: https://files.pythonhosted.org/packages/source/a/aioeventlet/aioeventlet-%{version}.tar.gz
# pr_1.patch is Python 3.7+ support
Patch0: pr_1.patch
# PATCH-FIX-OPENSUSE py311.patch Python 3.11+ support
Patch1: py311.patch
BuildRequires: %{python_module eventlet}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module setuptools}
@@ -54,8 +55,7 @@ in an greenthread while the Python main thread runs other greenthreads in
parallel.
%prep
%setup -q -n aioeventlet-%{intver}
%patch0 -p1
%autosetup -p1 -n aioeventlet-%{intver}
%build
%python_build
@@ -75,6 +75,8 @@ fi}
%files %{python_files}
%license COPYING
%doc README
%{python_sitelib}/*
%{python_sitelib}/aioeventlet.py
%{python_sitelib}/aioeventlet-%{intver}*-info
%pycache_only %{python_sitelib}/__pycache__
%changelog