From 560a5215c5a1dd1e33079e4cb19fe4ecb2ad49f8 Mon Sep 17 00:00:00 2001 From: matejcik Date: Tue, 6 Nov 2018 14:13:08 +0100 Subject: [PATCH] client: do not coerce self.features.vendor to string There is no good reason to do that and it hides situations when the field mistakenly doesn't exist. Added comment explains that missing "vendor" field might by caused by trezor-common mismatch, which fixes #328 --- trezorlib/client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/trezorlib/client.py b/trezorlib/client.py index 265ff87f1..57e1b5f54 100644 --- a/trezorlib/client.py +++ b/trezorlib/client.py @@ -180,8 +180,11 @@ class ProtocolMixin(object): raise exceptions.TrezorException("Unexpected initial response") else: self.features = resp - if str(self.features.vendor) not in self.VENDORS: + if self.features.vendor not in self.VENDORS: raise RuntimeError("Unsupported device") + # A side-effect of this is a sanity check for broken protobuf definitions. + # If the `vendor` field doesn't exist, you probably have a mismatched + # checkout of trezor-common. @staticmethod def expand_path(n):