Skip to content

Commit a43e4a3

Browse files
twondsclaude
andauthored
Fix Python 3 compatibility for newer Twisted (#73)
* Fix Python 3 compatibility: simplify putChild and add reactor to HttpbService Drop Python 2 support: replace the version-conditional double putChild call with a single b'http-bind' bytes call, and remove the now-unused sys import. Add self.reactor to HttpbService so newer Twisted (22+) can access site.reactor in server.Session.__init__. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Replace Travis CI with GitHub Actions Travis CI is no longer functional for this repo. Replace it with a GitHub Actions workflow that tests on Python 3.10-3.13 against both the latest Twisted release and Twisted trunk, with and without PyOpenSSL. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2c940c6 commit a43e4a3

File tree

4 files changed

+40
-35
lines changed

4 files changed

+40
-35
lines changed

.github/workflows/ci.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
python-version: ["3.10", "3.11", "3.12", "3.13"]
16+
twisted: ["Twisted", "git+https://github.com/twisted/twisted.git@trunk"]
17+
pyopenssl: ["", "PyOpenSSL"]
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
27+
- name: Install dependencies
28+
run: |
29+
pip install flake8 service_identity
30+
pip install "${{ matrix.twisted }}"
31+
if [ -n "${{ matrix.pyopenssl }}" ]; then
32+
pip install ${{ matrix.pyopenssl }}
33+
fi
34+
python setup.py install
35+
36+
- name: Run tests
37+
run: ./run_tests.sh

.travis.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

punjab.tac

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ from twisted.application import service, internet
66

77
from punjab.httpb import Httpb, HttpbService
88

9-
import sys
10-
119
root = static.File("./html")
1210

1311
# uncomment only one of the bosh lines, use_raw does no xml
@@ -21,10 +19,7 @@ bosh = HttpbService(1)
2119
# or a black list
2220
# bosh.block_list = ['jabber.org', '.thetofu.com']
2321

24-
root.putChild('http-bind', resource.IResource(bosh))
25-
26-
if sys.version_info[0] == 3:
27-
root.putChild(b'http-bind', resource.IResource(bosh))
22+
root.putChild(b'http-bind', resource.IResource(bosh))
2823

2924
site = server.Site(root)
3025

punjab/httpb.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44
from twisted.python import components
55
from twisted.web import server, resource
6-
from twisted.internet import defer, task
6+
from twisted.internet import defer, task, reactor
77
from twisted.python import log
88

99

@@ -590,6 +590,7 @@ def __init__(self,
590590
else:
591591
self.make_session = make_session
592592
self.v = verbose
593+
self.reactor = reactor
593594
self.sessions = {}
594595
self.polling = polling
595596
self.use_raw = use_raw

0 commit comments

Comments
 (0)