Skip to content

fix twisted 22.10.0 incompability #1604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ jobs:
sudo apt update
sudo apt install libenchant-dev libbz2-dev libsnappy-dev libunwind-dev libgirepository1.0-dev

- name: Set up Python 3.x
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: '3.x'
python-version: '3.10'
architecture: 'x64'

- name: Install Python package dependencies
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
# os: [ubuntu-20.04, macos-latest, windows-latest]

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

# https://github.blog/changelog/2020-04-15-github-actions-new-workflow-features/
Expand Down Expand Up @@ -137,10 +137,10 @@ jobs:
sudo apt update
sudo apt install libenchant-dev libbz2-dev libsnappy-dev libunwind-dev libgirepository1.0-dev

- name: Set up Python 3.x
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: '3.x'
python-version: '3.10'
architecture: 'x64'

- name: Install Python package dependencies
Expand Down
15 changes: 10 additions & 5 deletions autobahn/twisted/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@

from twisted.protocols.policies import ProtocolWrapper
try:
# noinspection PyUnresolvedReferences
from twisted.web.error import NoResource
# starting from Twisted 22.10.0 we have `notFound`
from twisted.web.pages import notFound
except ImportError:
# starting from Twisted 12.2, NoResource has moved
from twisted.web.resource import NoResource
try:
# In Twisted < 22.10.0 && > 12.2 this was called `NoResource`
from twisted.web.resource import NoResource as notFound
except ImportError:
# And in Twisted < 12.2 this was in a different place
from twisted.web.error import NoResource as notFound

from twisted.web.resource import IResource, Resource

# The following triggers an import of reactor at module level!
Expand Down Expand Up @@ -100,7 +105,7 @@ def getChildWithDefault(self, name, request):
"""
This resource cannot have children, hence this will always fail.
"""
return NoResource("No such child resource.")
return notFound(message="No such child resource.")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now both and old code should be better aligned...


def putChild(self, path, child):
"""
Expand Down