Skip to content

Commit 392e198

Browse files
authored
fix twisted 22.10.0 incompability (#1604)
* fix twisted 22.10.0 incompability * ci: explicitly set 3.10 for checks and docs job * ci: run tests on python 3.11
1 parent a99ff5d commit 392e198

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ jobs:
3333
sudo apt update
3434
sudo apt install libenchant-dev libbz2-dev libsnappy-dev libunwind-dev libgirepository1.0-dev
3535
36-
- name: Set up Python 3.x
36+
- name: Set up Python 3.10
3737
uses: actions/setup-python@v2
3838
with:
39-
python-version: '3.x'
39+
python-version: '3.10'
4040
architecture: 'x64'
4141

4242
- name: Install Python package dependencies
@@ -72,7 +72,7 @@ jobs:
7272
# os: [ubuntu-20.04, macos-latest, windows-latest]
7373

7474
# https://github.com/actions/setup-python#specifying-a-pypy-version
75-
python-version: ['3.7', '3.10', 'pypy-3.8']
75+
python-version: ['3.7', '3.11', 'pypy-3.8']
7676
framework: ['asyncio', 'tw1910', 'tw221', 'twtrunk']
7777

7878
# https://github.blog/changelog/2020-04-15-github-actions-new-workflow-features/
@@ -137,10 +137,10 @@ jobs:
137137
sudo apt update
138138
sudo apt install libenchant-dev libbz2-dev libsnappy-dev libunwind-dev libgirepository1.0-dev
139139
140-
- name: Set up Python 3.x
140+
- name: Set up Python 3.10
141141
uses: actions/setup-python@v2
142142
with:
143-
python-version: '3.x'
143+
python-version: '3.10'
144144
architecture: 'x64'
145145

146146
- name: Install Python package dependencies

autobahn/twisted/resource.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,16 @@
2929

3030
from twisted.protocols.policies import ProtocolWrapper
3131
try:
32-
# noinspection PyUnresolvedReferences
33-
from twisted.web.error import NoResource
32+
# starting from Twisted 22.10.0 we have `notFound`
33+
from twisted.web.pages import notFound
3434
except ImportError:
35-
# starting from Twisted 12.2, NoResource has moved
36-
from twisted.web.resource import NoResource
35+
try:
36+
# In Twisted < 22.10.0 && > 12.2 this was called `NoResource`
37+
from twisted.web.resource import NoResource as notFound
38+
except ImportError:
39+
# And in Twisted < 12.2 this was in a different place
40+
from twisted.web.error import NoResource as notFound
41+
3742
from twisted.web.resource import IResource, Resource
3843

3944
# The following triggers an import of reactor at module level!
@@ -100,7 +105,7 @@ def getChildWithDefault(self, name, request):
100105
"""
101106
This resource cannot have children, hence this will always fail.
102107
"""
103-
return NoResource("No such child resource.")
108+
return notFound(message="No such child resource.")
104109

105110
def putChild(self, path, child):
106111
"""

0 commit comments

Comments
 (0)