commit 7507edec828603a860d9ebf0cbb049060d32fc3e Author: Damian Johnson atagar@torproject.org Date: Sun Jan 27 17:41:08 2013 -0800
Converting tor initialization lines to unicode
The stdout of the tor process is an ASCII byte stream, causing our following regex search() call to error. --- stem/process.py | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/stem/process.py b/stem/process.py index 19d9028..52a931e 100644 --- a/stem/process.py +++ b/stem/process.py @@ -127,7 +127,14 @@ def launch_tor(tor_cmd = "tor", args = None, torrc_path = None, completion_perce last_problem = "Timed out"
while True: - init_line = tor_process.stdout.readline().strip() + # Tor's stdout will be read as ASCII bytes. This is fine for python 2, but + # in python 3 that means it'll mismatch with other operations (for instance + # the bootstrap_line.search() call later will fail). + # + # It seems like python 2.x is perfectly happy for this to be unicode, so + # normalizing to that. + + init_line = tor_process.stdout.readline().decode("utf-8", "replace").strip()
# this will provide empty results if the process is terminated if not init_line:
tor-commits@lists.torproject.org