From 540fceb795f73215927b686a3fb19b0113b20995 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Mon, 28 Sep 2015 16:04:54 -0700 Subject: [PATCH] add py3.4 compatibility The "bytes % bytes" syntax only appeared on py3.5, so don't use it. Updated travis to expect py3.4 works. The twisted side is probably even more broken for py3.4 than it is for py3.5. --- .travis.yml | 1 - src/wormhole/blocking/transit.py | 6 +++--- src/wormhole/servers/relay.py | 10 +++++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index fb15cdd..c4c425c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,6 @@ python: matrix: allow_failures: - python: "3.3" - - python: "3.4" fast_finish: true install: - pip install . Twisted pyflakes diff --git a/src/wormhole/blocking/transit.py b/src/wormhole/blocking/transit.py index 9732c7c..718695a 100644 --- a/src/wormhole/blocking/transit.py +++ b/src/wormhole/blocking/transit.py @@ -42,15 +42,15 @@ class TransitError(Exception): def build_receiver_handshake(key): hexid = HKDF(key, 32, CTXinfo=b"transit_receiver") - return b"transit receiver %s ready\n\n" % hexlify(hexid) + return b"transit receiver "+hexlify(hexid)+b" ready\n\n" def build_sender_handshake(key): hexid = HKDF(key, 32, CTXinfo=b"transit_sender") - return b"transit sender %s ready\n\n" % hexlify(hexid) + return b"transit sender "+hexlify(hexid)+b" ready\n\n" def build_relay_handshake(key): token = HKDF(key, 32, CTXinfo=b"transit_relay_token") - return b"please relay %s\n" % hexlify(token) + return b"please relay "+hexlify(token)+b"\n" TIMEOUT=15 diff --git a/src/wormhole/servers/relay.py b/src/wormhole/servers/relay.py index 2e87717..ae79163 100644 --- a/src/wormhole/servers/relay.py +++ b/src/wormhole/servers/relay.py @@ -26,23 +26,23 @@ class EventsProtocol: # face of firewall/NAT timeouts. It also helps unit tests, since # apparently twisted.web.client.Agent doesn't consider the connection # to be established until it sees the first byte of the reponse body. - self.request.write(b": %s\n\n" % comment) + self.request.write(b": " + comment + b"\n\n") def sendEvent(self, data, name=None, id=None, retry=None): if name: - self.request.write(b"event: %s\n" % name.encode("utf-8")) + self.request.write(b"event: " + name.encode("utf-8") + b"\n") # e.g. if name=foo, then the client web page should do: # (new EventSource(url)).addEventListener("foo", handlerfunc) # Note that this basically defaults to "message". self.request.write(b"\n") if id: - self.request.write(b"id: %s\n" % id.encode("utf-8")) + self.request.write(b"id: " + id.encode("utf-8") + b"\n") self.request.write(b"\n") if retry: - self.request.write(b"retry: %d\n" % retry) # milliseconds + self.request.write(b"retry: " + retry + b"\n") # milliseconds self.request.write(b"\n") for line in data.splitlines(): - self.request.write(b"data: %s\n" % line.encode("utf-8")) + self.request.write(b"data: " + line.encode("utf-8") + b"\n") self.request.write(b"\n") def stop(self):