Skip to content

Commit 112e474

Browse files
authored
Merge pull request #196 from thomwiggers/fix-py310-compat
Fix python 3.10 compatibility issues
2 parents 03850b8 + 5360902 commit 112e474

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

.github/workflows/tox.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
python: [3.5, 3.6, 3.7, 3.8, 3.9]
11+
python: [3.5, 3.6, 3.7, 3.8, 3.9, "3.10"]
1212

1313
steps:
1414
- uses: actions/checkout@v2

irc3/compat.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
PY34 = bool(sys.version_info[0:2] >= (3, 4))
66
PY35 = bool(sys.version_info[0:2] >= (3, 5))
7+
PY37 = bool(sys.version_info[0:2] >= (3, 7))
78

89

910
try: # pragma: no cover
@@ -13,9 +14,36 @@
1314

1415
try: # pragma: no cover
1516
import asyncio
16-
from asyncio.queues import Queue
17+
from asyncio.queues import Queue as BaseQueue
1718
from asyncio.queues import QueueFull # NOQA
19+
from asyncio import sleep as _original_sleep
20+
from asyncio import wait as _original_wait
1821
except ImportError: # pragma: no cover
1922
import trollius as asyncio # NOQA
20-
from trollius.queues import Queue # NOQA
23+
from trollius.queues import Queue as BaseQueue # NOQA
2124
from trollius.queues import QueueFull # NOQA
25+
from trollius import sleep as _original_sleep
26+
from trollius import wait as _original_wait
27+
28+
29+
def __sleep(*args, **kwargs):
30+
if PY37 and "loop" in kwargs:
31+
del kwargs["loop"]
32+
return _original_sleep(*args, **kwargs)
33+
34+
35+
def __wait(*args, **kwargs):
36+
if PY37 and "loop" in kwargs:
37+
del kwargs["loop"]
38+
return _original_wait(*args, **kwargs)
39+
40+
41+
asyncio.sleep = __sleep
42+
asyncio.wait = __wait
43+
44+
class Queue(BaseQueue):
45+
def __init__(self, *args, **kwargs):
46+
if PY37 and "loop" in kwargs:
47+
del kwargs["loop"]
48+
49+
super().__init__(*args, **kwargs)

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py35,py36,py37,py38,py39,flake8,docs
2+
envlist = py35,py36,py37,py38,py39,py310,flake8,docs
33

44
[testenv]
55
skipsdist=true

0 commit comments

Comments
 (0)