commit 5e6b5407f087b6b31d28ed5047e44b07f082d197 Author: Damian Johnson atagar@torproject.org Date: Sun Mar 24 21:05:14 2013 -0700
Controller provided unicode microdescriptors with python 3
When using python 3 the get_info() method provides unicode content. We were passing this content to descriptor constructors, causing its raw_content to be unicode rather than bytes. This in turn caused a stacktrace when calling methods like hashlib.sha256().
This doesn't effect python 2.x, where str is bytes anyway. --- stem/control.py | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/stem/control.py b/stem/control.py index 82cff41..5b9a8ac 100644 --- a/stem/control.py +++ b/stem/control.py @@ -989,7 +989,7 @@ class Controller(BaseController): raise ValueError("'%s' isn't a valid fingerprint or nickname" % relay)
desc_content = self.get_info(query) - return stem.descriptor.microdescriptor.Microdescriptor(desc_content) + return stem.descriptor.microdescriptor.Microdescriptor(str_tools._to_bytes(desc_content)) except Exception, exc: if default == UNDEFINED: raise exc @@ -1079,7 +1079,7 @@ class Controller(BaseController): raise ValueError("'%s' isn't a valid fingerprint or nickname" % relay)
desc_content = self.get_info(query) - return stem.descriptor.server_descriptor.RelayDescriptor(desc_content) + return stem.descriptor.server_descriptor.RelayDescriptor(str_tools._to_bytes(desc_content)) except Exception, exc: if default == UNDEFINED: raise exc @@ -1153,7 +1153,7 @@ class Controller(BaseController): raise ValueError("'%s' isn't a valid fingerprint or nickname" % relay)
desc_content = self.get_info(query) - return stem.descriptor.router_status_entry.RouterStatusEntryV2(desc_content) + return stem.descriptor.router_status_entry.RouterStatusEntryV2(str_tools._to_bytes(desc_content)) except Exception, exc: if default == UNDEFINED: raise exc
tor-commits@lists.torproject.org