From 4f8aa5a69ed012745a1dcd128a0c075e359dc485 Mon Sep 17 00:00:00 2001 From: Baeumla Date: Thu, 8 Mar 2018 11:54:27 +0100 Subject: [PATCH 1/7] report clinet version on bind --- src/wormhole/_boss.py | 6 +++++- src/wormhole/_rendezvous.py | 5 ++++- src/wormhole/cli/cli.py | 1 + src/wormhole/cli/cmd_receive.py | 2 ++ src/wormhole/cli/cmd_send.py | 2 ++ src/wormhole/test/test_machines.py | 14 ++++++++++---- src/wormhole/test/test_wormhole.py | 8 ++++---- src/wormhole/wormhole.py | 10 ++++++++-- 8 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/wormhole/_boss.py b/src/wormhole/_boss.py index 33c00e2..cd97145 100644 --- a/src/wormhole/_boss.py +++ b/src/wormhole/_boss.py @@ -32,10 +32,12 @@ class Boss(object): _url = attrib(validator=instance_of(type(u""))) _appid = attrib(validator=instance_of(type(u""))) _versions = attrib(validator=instance_of(dict)) + _wormhole_version = attrib(validator=instance_of(type(u""))) _reactor = attrib() _journal = attrib(validator=provides(_interfaces.IJournal)) _tor = attrib(validator=optional(provides(_interfaces.ITorManager))) _timing = attrib(validator=provides(_interfaces.ITiming)) + _implementation = attrib(validator=instance_of(type(u""))) m = MethodicalMachine() set_trace = getattr(m, "_setTrace", lambda self, f: None) # pragma: no cover @@ -52,7 +54,9 @@ class Boss(object): self._R = Receive(self._side, self._timing) self._RC = RendezvousConnector(self._url, self._appid, self._side, self._reactor, self._journal, - self._tor, self._timing) + self._tor, self._timing, + self._wormhole_version, + self._implementation) self._L = Lister(self._timing) self._A = Allocator(self._timing) self._I = Input(self._timing) diff --git a/src/wormhole/_rendezvous.py b/src/wormhole/_rendezvous.py index 28a64cd..e55b902 100644 --- a/src/wormhole/_rendezvous.py +++ b/src/wormhole/_rendezvous.py @@ -67,6 +67,8 @@ class RendezvousConnector(object): _journal = attrib(validator=provides(_interfaces.IJournal)) _tor = attrib(validator=optional(provides(_interfaces.ITorManager))) _timing = attrib(validator=provides(_interfaces.ITiming)) + _wormhole_version = attrib(validator=instance_of(type(u""))) + _implementation = attrib(validator=instance_of(type(u""))) def __attrs_post_init__(self): self._have_made_a_successful_connection = False @@ -165,7 +167,8 @@ class RendezvousConnector(object): self._have_made_a_successful_connection = True self._ws = proto try: - self._tx("bind", appid=self._appid, side=self._side) + self._tx("bind", appid=self._appid, side=self._side, + implementation=self._implementation, wormhole_version=self._wormhole_version) self._N.connected() self._M.connected() self._L.connected() diff --git a/src/wormhole/cli/cli.py b/src/wormhole/cli/cli.py index 58ccd8f..9be4545 100644 --- a/src/wormhole/cli/cli.py +++ b/src/wormhole/cli/cli.py @@ -94,6 +94,7 @@ def wormhole(context, dump_timing, transit_helper, relay_url, appid): cfg.relay_url = relay_url cfg.transit_helper = transit_helper cfg.dump_timing = dump_timing + cfg.version = __version__ @inlineCallbacks diff --git a/src/wormhole/cli/cmd_receive.py b/src/wormhole/cli/cmd_receive.py index 1cb457b..3cd48d1 100644 --- a/src/wormhole/cli/cmd_receive.py +++ b/src/wormhole/cli/cmd_receive.py @@ -47,6 +47,7 @@ class Receiver: self._reactor = reactor self._tor = None self._transit_receiver = None + self._version = {"v1" : args.version} def _msg(self, *args, **kwargs): print(*args, file=self.args.stderr, **kwargs) @@ -67,6 +68,7 @@ class Receiver: w = create(self.args.appid or APPID, self.args.relay_url, self._reactor, + versions = self._version, tor=self._tor, timing=self.args.timing) self._w = w # so tests can wait on events too diff --git a/src/wormhole/cli/cmd_send.py b/src/wormhole/cli/cmd_send.py index 969ab0f..2d37d2c 100644 --- a/src/wormhole/cli/cmd_send.py +++ b/src/wormhole/cli/cmd_send.py @@ -34,6 +34,7 @@ class Sender: self._timing = args.timing self._fd_to_send = None self._transit_sender = None + self._version = {"v1" : args.version} @inlineCallbacks def go(self): @@ -52,6 +53,7 @@ class Sender: w = create(self._args.appid or APPID, self._args.relay_url, self._reactor, + versions = self._version, tor=self._tor, timing=self._timing) d = self._go(w) diff --git a/src/wormhole/test/test_machines.py b/src/wormhole/test/test_machines.py index 52a2d0c..1250e56 100644 --- a/src/wormhole/test/test_machines.py +++ b/src/wormhole/test/test_machines.py @@ -1216,12 +1216,14 @@ class Boss(unittest.TestCase): "got_code", "got_key", "got_verifier", "got_versions", "received", "closed") versions = {"app": "version1"} + version = "version1" reactor = None journal = ImmediateJournal() tor_manager = None + implementation = "python" b = MockBoss(wormhole, "side", "url", "appid", versions, - reactor, journal, tor_manager, - timing.DebugTiming()) + version, reactor, journal, tor_manager, + timing.DebugTiming(), implementation) b._T = Dummy("t", events, ITerminator, "close") b._S = Dummy("s", events, ISend, "send") b._RC = Dummy("rc", events, IRendezvousConnector, "start") @@ -1449,10 +1451,13 @@ class Rendezvous(unittest.TestCase): reactor = object() journal = ImmediateJournal() tor_manager = None + wormhole_version = "version1" + implementation = "python" rc = _rendezvous.RendezvousConnector("ws://host:4000/v1", "appid", "side", reactor, journal, tor_manager, - timing.DebugTiming()) + timing.DebugTiming(), + wormhole_version, implementation) b = Dummy("b", events, IBoss, "error") n = Dummy("n", events, INameplate, "connected", "lost") m = Dummy("m", events, IMailbox, "connected", "lost") @@ -1502,7 +1507,8 @@ class Rendezvous(unittest.TestCase): yield bytes_to_dict(c[1][0]) self.assertEqual(list(sent_messages(ws)), [dict(appid="appid", side="side", id="0000", - type="bind"), + type="bind", wormhole_version="version1", + implementation="python"), ]) rc.ws_close(True, None, None) diff --git a/src/wormhole/test/test_wormhole.py b/src/wormhole/test/test_wormhole.py index df5830f..ce3e302 100644 --- a/src/wormhole/test/test_wormhole.py +++ b/src/wormhole/test/test_wormhole.py @@ -526,16 +526,16 @@ class Wormholes(ServerBase, unittest.TestCase): def test_versions(self): # there's no API for this yet, but make sure the internals work w1 = wormhole.create(APPID, self.relayurl, reactor, - versions={"w1": 123}) + versions={"w1": "123"}) w2 = wormhole.create(APPID, self.relayurl, reactor, - versions={"w2": 456}) + versions={"w2": "456"}) w1.allocate_code() code = yield w1.get_code() w2.set_code(code) w1_versions = yield w2.get_versions() - self.assertEqual(w1_versions, {"w1": 123}) + self.assertEqual(w1_versions, {"w1": "123"}) w2_versions = yield w1.get_versions() - self.assertEqual(w2_versions, {"w2": 456}) + self.assertEqual(w2_versions, {"w2": "456"}) yield w1.close() yield w2.close() diff --git a/src/wormhole/wormhole.py b/src/wormhole/wormhole.py index 72feb07..12a9c7e 100644 --- a/src/wormhole/wormhole.py +++ b/src/wormhole/wormhole.py @@ -230,8 +230,14 @@ def create(appid, relay_url, reactor, # use keyword args for everything else w = _DeferredWormhole(eq) wormhole_versions = {} # will be used to indicate Wormhole capabilities wormhole_versions["app_versions"] = versions # app-specific capabilities - b = Boss(w, side, relay_url, appid, wormhole_versions, - reactor, journal, tor, timing) + #version to be sent with bind if provided + if type(versions) is dict and versions != {} : + wormhole_version = list(versions.values())[0] or "" + else: + wormhole_version = versions or "" + implementation = "python" + b = Boss(w, side, relay_url, appid, wormhole_versions, wormhole_version, + reactor, journal, tor, timing, implementation) w._set_boss(b) b.start() return w From 0322d341e8b9a9954867b6614c571af782342b94 Mon Sep 17 00:00:00 2001 From: Baeumla Date: Fri, 9 Mar 2018 09:31:59 +0100 Subject: [PATCH 2/7] py 2.7 fix --- src/wormhole/wormhole.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wormhole/wormhole.py b/src/wormhole/wormhole.py index 12a9c7e..e65003c 100644 --- a/src/wormhole/wormhole.py +++ b/src/wormhole/wormhole.py @@ -231,10 +231,12 @@ def create(appid, relay_url, reactor, # use keyword args for everything else wormhole_versions = {} # will be used to indicate Wormhole capabilities wormhole_versions["app_versions"] = versions # app-specific capabilities #version to be sent with bind if provided + wormhole_version = u"" if type(versions) is dict and versions != {} : wormhole_version = list(versions.values())[0] or "" else: wormhole_version = versions or "" + wormhole_version = wormhole_version.decode('unicode-escape') implementation = "python" b = Boss(w, side, relay_url, appid, wormhole_versions, wormhole_version, reactor, journal, tor, timing, implementation) From 82dc4a4e2ece18c30e55a9ee60388108ec0c80e1 Mon Sep 17 00:00:00 2001 From: Baeumla Date: Fri, 9 Mar 2018 10:20:03 +0100 Subject: [PATCH 3/7] py 2.7 3.x fix --- src/wormhole/wormhole.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wormhole/wormhole.py b/src/wormhole/wormhole.py index e65003c..4ffcfa7 100644 --- a/src/wormhole/wormhole.py +++ b/src/wormhole/wormhole.py @@ -236,7 +236,9 @@ def create(appid, relay_url, reactor, # use keyword args for everything else wormhole_version = list(versions.values())[0] or "" else: wormhole_version = versions or "" - wormhole_version = wormhole_version.decode('unicode-escape') + #workaround for py2.7, py3.X + if sys.version_info < (3, 0): + wormhole_version = wormhole_version.decode('unicode-escape') implementation = "python" b = Boss(w, side, relay_url, appid, wormhole_versions, wormhole_version, reactor, journal, tor, timing, implementation) @@ -253,6 +255,6 @@ def create(appid, relay_url, reactor, # use keyword args for everything else ## # now unpack state machines, including the SPAKE2 in Key ## b = Boss.from_serialized(w, serialized["boss"], reactor, journal, timing) ## w._set_boss(b) -## b.start() # ?? +## b .start() # ?? ## raise NotImplemented ## # should the new Wormhole call got_code? only if it wasn't called before. From e77a2d605b9255c81ce84b214b0c99adff1cf227 Mon Sep 17 00:00:00 2001 From: Baime Date: Fri, 23 Mar 2018 17:33:48 +0100 Subject: [PATCH 4/7] bind passes tuple, fixed implementation issues --- src/wormhole/_boss.py | 6 ++---- src/wormhole/_rendezvous.py | 5 ++--- src/wormhole/cli/cli.py | 1 - src/wormhole/cli/cmd_receive.py | 2 -- src/wormhole/cli/cmd_send.py | 2 -- src/wormhole/test/test_machines.py | 23 +++++++++++------------ src/wormhole/test/test_wormhole.py | 8 ++++---- src/wormhole/wormhole.py | 18 +++++------------- 8 files changed, 24 insertions(+), 41 deletions(-) diff --git a/src/wormhole/_boss.py b/src/wormhole/_boss.py index cd97145..c99bb3d 100644 --- a/src/wormhole/_boss.py +++ b/src/wormhole/_boss.py @@ -32,12 +32,11 @@ class Boss(object): _url = attrib(validator=instance_of(type(u""))) _appid = attrib(validator=instance_of(type(u""))) _versions = attrib(validator=instance_of(dict)) - _wormhole_version = attrib(validator=instance_of(type(u""))) + _client_version = attrib(validator=instance_of(tuple)) _reactor = attrib() _journal = attrib(validator=provides(_interfaces.IJournal)) _tor = attrib(validator=optional(provides(_interfaces.ITorManager))) _timing = attrib(validator=provides(_interfaces.ITiming)) - _implementation = attrib(validator=instance_of(type(u""))) m = MethodicalMachine() set_trace = getattr(m, "_setTrace", lambda self, f: None) # pragma: no cover @@ -55,8 +54,7 @@ class Boss(object): self._RC = RendezvousConnector(self._url, self._appid, self._side, self._reactor, self._journal, self._tor, self._timing, - self._wormhole_version, - self._implementation) + self._client_version) self._L = Lister(self._timing) self._A = Allocator(self._timing) self._I = Input(self._timing) diff --git a/src/wormhole/_rendezvous.py b/src/wormhole/_rendezvous.py index e55b902..22d214a 100644 --- a/src/wormhole/_rendezvous.py +++ b/src/wormhole/_rendezvous.py @@ -67,8 +67,7 @@ class RendezvousConnector(object): _journal = attrib(validator=provides(_interfaces.IJournal)) _tor = attrib(validator=optional(provides(_interfaces.ITorManager))) _timing = attrib(validator=provides(_interfaces.ITiming)) - _wormhole_version = attrib(validator=instance_of(type(u""))) - _implementation = attrib(validator=instance_of(type(u""))) + _client_version = attrib(validator=instance_of(tuple)) def __attrs_post_init__(self): self._have_made_a_successful_connection = False @@ -168,7 +167,7 @@ class RendezvousConnector(object): self._ws = proto try: self._tx("bind", appid=self._appid, side=self._side, - implementation=self._implementation, wormhole_version=self._wormhole_version) + client_version=self._client_version) self._N.connected() self._M.connected() self._L.connected() diff --git a/src/wormhole/cli/cli.py b/src/wormhole/cli/cli.py index 9be4545..58ccd8f 100644 --- a/src/wormhole/cli/cli.py +++ b/src/wormhole/cli/cli.py @@ -94,7 +94,6 @@ def wormhole(context, dump_timing, transit_helper, relay_url, appid): cfg.relay_url = relay_url cfg.transit_helper = transit_helper cfg.dump_timing = dump_timing - cfg.version = __version__ @inlineCallbacks diff --git a/src/wormhole/cli/cmd_receive.py b/src/wormhole/cli/cmd_receive.py index 3cd48d1..1cb457b 100644 --- a/src/wormhole/cli/cmd_receive.py +++ b/src/wormhole/cli/cmd_receive.py @@ -47,7 +47,6 @@ class Receiver: self._reactor = reactor self._tor = None self._transit_receiver = None - self._version = {"v1" : args.version} def _msg(self, *args, **kwargs): print(*args, file=self.args.stderr, **kwargs) @@ -68,7 +67,6 @@ class Receiver: w = create(self.args.appid or APPID, self.args.relay_url, self._reactor, - versions = self._version, tor=self._tor, timing=self.args.timing) self._w = w # so tests can wait on events too diff --git a/src/wormhole/cli/cmd_send.py b/src/wormhole/cli/cmd_send.py index 2d37d2c..969ab0f 100644 --- a/src/wormhole/cli/cmd_send.py +++ b/src/wormhole/cli/cmd_send.py @@ -34,7 +34,6 @@ class Sender: self._timing = args.timing self._fd_to_send = None self._transit_sender = None - self._version = {"v1" : args.version} @inlineCallbacks def go(self): @@ -53,7 +52,6 @@ class Sender: w = create(self._args.appid or APPID, self._args.relay_url, self._reactor, - versions = self._version, tor=self._tor, timing=self._timing) d = self._go(w) diff --git a/src/wormhole/test/test_machines.py b/src/wormhole/test/test_machines.py index 1250e56..0d617bb 100644 --- a/src/wormhole/test/test_machines.py +++ b/src/wormhole/test/test_machines.py @@ -5,7 +5,7 @@ from zope.interface import directlyProvides, implementer from twisted.trial import unittest from .. import (errors, timing, _order, _receive, _key, _code, _lister, _boss, _input, _allocator, _send, _terminator, _nameplate, _mailbox, - _rendezvous) + _rendezvous, __version__) from .._interfaces import (IKey, IReceive, IBoss, ISend, IMailbox, IOrder, IRendezvousConnector, ILister, IInput, IAllocator, INameplate, ICode, IWordlist, ITerminator) @@ -1216,14 +1216,13 @@ class Boss(unittest.TestCase): "got_code", "got_key", "got_verifier", "got_versions", "received", "closed") versions = {"app": "version1"} - version = "version1" reactor = None journal = ImmediateJournal() tor_manager = None - implementation = "python" + client_version = ("python", __version__) b = MockBoss(wormhole, "side", "url", "appid", versions, - version, reactor, journal, tor_manager, - timing.DebugTiming(), implementation) + client_version, reactor, journal, tor_manager, + timing.DebugTiming()) b._T = Dummy("t", events, ITerminator, "close") b._S = Dummy("s", events, ISend, "send") b._RC = Dummy("rc", events, IRendezvousConnector, "start") @@ -1451,13 +1450,13 @@ class Rendezvous(unittest.TestCase): reactor = object() journal = ImmediateJournal() tor_manager = None - wormhole_version = "version1" - implementation = "python" + client_version = ("python", __version__) + print(client_version) rc = _rendezvous.RendezvousConnector("ws://host:4000/v1", "appid", "side", reactor, journal, tor_manager, - timing.DebugTiming(), - wormhole_version, implementation) + timing.DebugTiming(), + client_version) b = Dummy("b", events, IBoss, "error") n = Dummy("n", events, INameplate, "connected", "lost") m = Dummy("m", events, IMailbox, "connected", "lost") @@ -1506,9 +1505,9 @@ class Rendezvous(unittest.TestCase): self.assertEqual(c[1][1], False, ws.mock_calls) yield bytes_to_dict(c[1][0]) self.assertEqual(list(sent_messages(ws)), - [dict(appid="appid", side="side", id="0000", - type="bind", wormhole_version="version1", - implementation="python"), + [dict(appid="appid", side="side", + client_version=["python", __version__], + id="0000", type="bind"), ]) rc.ws_close(True, None, None) diff --git a/src/wormhole/test/test_wormhole.py b/src/wormhole/test/test_wormhole.py index ce3e302..df5830f 100644 --- a/src/wormhole/test/test_wormhole.py +++ b/src/wormhole/test/test_wormhole.py @@ -526,16 +526,16 @@ class Wormholes(ServerBase, unittest.TestCase): def test_versions(self): # there's no API for this yet, but make sure the internals work w1 = wormhole.create(APPID, self.relayurl, reactor, - versions={"w1": "123"}) + versions={"w1": 123}) w2 = wormhole.create(APPID, self.relayurl, reactor, - versions={"w2": "456"}) + versions={"w2": 456}) w1.allocate_code() code = yield w1.get_code() w2.set_code(code) w1_versions = yield w2.get_versions() - self.assertEqual(w1_versions, {"w1": "123"}) + self.assertEqual(w1_versions, {"w1": 123}) w2_versions = yield w1.get_versions() - self.assertEqual(w2_versions, {"w2": "456"}) + self.assertEqual(w2_versions, {"w2": 456}) yield w1.close() yield w2.close() diff --git a/src/wormhole/wormhole.py b/src/wormhole/wormhole.py index 4ffcfa7..11ff7cc 100644 --- a/src/wormhole/wormhole.py +++ b/src/wormhole/wormhole.py @@ -3,6 +3,7 @@ import os, sys from attr import attrs, attrib from zope.interface import implementer from twisted.python import failure +from . import __version__ from ._interfaces import IWormhole, IDeferredWormhole from .util import bytes_to_hexstr from .eventual import EventualQueue @@ -230,18 +231,9 @@ def create(appid, relay_url, reactor, # use keyword args for everything else w = _DeferredWormhole(eq) wormhole_versions = {} # will be used to indicate Wormhole capabilities wormhole_versions["app_versions"] = versions # app-specific capabilities - #version to be sent with bind if provided - wormhole_version = u"" - if type(versions) is dict and versions != {} : - wormhole_version = list(versions.values())[0] or "" - else: - wormhole_version = versions or "" - #workaround for py2.7, py3.X - if sys.version_info < (3, 0): - wormhole_version = wormhole_version.decode('unicode-escape') - implementation = "python" - b = Boss(w, side, relay_url, appid, wormhole_versions, wormhole_version, - reactor, journal, tor, timing, implementation) + client_version = ("python", __version__.decode("utf-8", errors="replace")) + b = Boss(w, side, relay_url, appid, wormhole_versions, client_version, + reactor, journal, tor, timing) w._set_boss(b) b.start() return w @@ -255,6 +247,6 @@ def create(appid, relay_url, reactor, # use keyword args for everything else ## # now unpack state machines, including the SPAKE2 in Key ## b = Boss.from_serialized(w, serialized["boss"], reactor, journal, timing) ## w._set_boss(b) -## b .start() # ?? +## b.start() # ?? ## raise NotImplemented ## # should the new Wormhole call got_code? only if it wasn't called before. From 1197e5fb6d37aef7c57872df71d42ebf1785fd53 Mon Sep 17 00:00:00 2001 From: Baime Date: Fri, 23 Mar 2018 18:19:31 +0100 Subject: [PATCH 5/7] fix py 3.x versioneer issue --- src/wormhole/wormhole.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wormhole/wormhole.py b/src/wormhole/wormhole.py index 11ff7cc..c1bda16 100644 --- a/src/wormhole/wormhole.py +++ b/src/wormhole/wormhole.py @@ -231,7 +231,11 @@ def create(appid, relay_url, reactor, # use keyword args for everything else w = _DeferredWormhole(eq) wormhole_versions = {} # will be used to indicate Wormhole capabilities wormhole_versions["app_versions"] = versions # app-specific capabilities - client_version = ("python", __version__.decode("utf-8", errors="replace")) + if (type(__version__) == str): + client_version = ("python", __version__) + else: + client_version = ("python", __version__.decode("utf-8", errors="replace")) + b = Boss(w, side, relay_url, appid, wormhole_versions, client_version, reactor, journal, tor, timing) w._set_boss(b) From 0dd3a12546a75642ff834cc8774c425a42ef4b57 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Tue, 3 Apr 2018 17:05:33 -0700 Subject: [PATCH 6/7] cosmetic changes, remove debug print --- src/wormhole/_rendezvous.py | 2 +- src/wormhole/test/test_machines.py | 3 +-- src/wormhole/wormhole.py | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/wormhole/_rendezvous.py b/src/wormhole/_rendezvous.py index 22d214a..963d12a 100644 --- a/src/wormhole/_rendezvous.py +++ b/src/wormhole/_rendezvous.py @@ -167,7 +167,7 @@ class RendezvousConnector(object): self._ws = proto try: self._tx("bind", appid=self._appid, side=self._side, - client_version=self._client_version) + client_version=self._client_version) self._N.connected() self._M.connected() self._L.connected() diff --git a/src/wormhole/test/test_machines.py b/src/wormhole/test/test_machines.py index 0d617bb..ec96fc0 100644 --- a/src/wormhole/test/test_machines.py +++ b/src/wormhole/test/test_machines.py @@ -1451,7 +1451,6 @@ class Rendezvous(unittest.TestCase): journal = ImmediateJournal() tor_manager = None client_version = ("python", __version__) - print(client_version) rc = _rendezvous.RendezvousConnector("ws://host:4000/v1", "appid", "side", reactor, journal, tor_manager, @@ -1505,7 +1504,7 @@ class Rendezvous(unittest.TestCase): self.assertEqual(c[1][1], False, ws.mock_calls) yield bytes_to_dict(c[1][0]) self.assertEqual(list(sent_messages(ws)), - [dict(appid="appid", side="side", + [dict(appid="appid", side="side", client_version=["python", __version__], id="0000", type="bind"), ]) diff --git a/src/wormhole/wormhole.py b/src/wormhole/wormhole.py index c1bda16..7522f8d 100644 --- a/src/wormhole/wormhole.py +++ b/src/wormhole/wormhole.py @@ -231,11 +231,10 @@ def create(appid, relay_url, reactor, # use keyword args for everything else w = _DeferredWormhole(eq) wormhole_versions = {} # will be used to indicate Wormhole capabilities wormhole_versions["app_versions"] = versions # app-specific capabilities - if (type(__version__) == str): + if type(__version__) == str: client_version = ("python", __version__) else: client_version = ("python", __version__.decode("utf-8", errors="replace")) - b = Boss(w, side, relay_url, appid, wormhole_versions, client_version, reactor, journal, tor, timing) w._set_boss(b) From 5c84f6a37336feea1c4416eab0a2298bb59ae68c Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Tue, 3 Apr 2018 17:10:46 -0700 Subject: [PATCH 7/7] wormhole: slightly different way to unicode-encode the version (this is somewhat more in line with how this distinction is made elsewhere in the code) --- src/wormhole/wormhole.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wormhole/wormhole.py b/src/wormhole/wormhole.py index 7522f8d..311e3fc 100644 --- a/src/wormhole/wormhole.py +++ b/src/wormhole/wormhole.py @@ -231,10 +231,10 @@ def create(appid, relay_url, reactor, # use keyword args for everything else w = _DeferredWormhole(eq) wormhole_versions = {} # will be used to indicate Wormhole capabilities wormhole_versions["app_versions"] = versions # app-specific capabilities - if type(__version__) == str: - client_version = ("python", __version__) - else: - client_version = ("python", __version__.decode("utf-8", errors="replace")) + v = __version__ + if isinstance(v, type(b"")): + v = v.decode("utf-8", errors="replace") + client_version = ("python", v) b = Boss(w, side, relay_url, appid, wormhole_versions, client_version, reactor, journal, tor, timing) w._set_boss(b)