[tor-commits] [stem/master] BandwidthFile python 3.x regression

atagar at torproject.org atagar at torproject.org
Tue Feb 5 21:43:26 UTC 2019

commit f1c6e30dbb9ca739df3b577bf0a5f547d5383b3a
Author: Damian Johnson <atagar at torproject.org>
Date:   Tue Feb 5 13:41:55 2019 -0800

    BandwidthFile python 3.x regression
    Oops, forgot to re-run tests with python 3.x. Recent change had a bytes/unicode
    regression slip in...
      ERROR: test_format_v1_2
      Traceback (most recent call last):
        File "/home/atagar/Desktop/stem/test/unit/descriptor/bandwidth_file.py", line 103, in test_format_v1_2
          self.assertEqual('1.2.0', desc.version)
        File "/home/atagar/Desktop/stem/stem/descriptor/__init__.py", line 1041, in __getattr__
          parsing_function(self, self._entries)
        File "/home/atagar/Desktop/stem/stem/descriptor/bandwidth_file.py", line 116, in _parse_header
          elif not header and 'node_id=' in line:
      TypeError: a bytes-like object is required, not 'str'
 stem/descriptor/bandwidth_file.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/stem/descriptor/bandwidth_file.py b/stem/descriptor/bandwidth_file.py
index e2a420ef..f73dc007 100644
--- a/stem/descriptor/bandwidth_file.py
+++ b/stem/descriptor/bandwidth_file.py
@@ -113,7 +113,7 @@ def _parse_header(descriptor, entries):
       break  # end of the content
     elif line in (HEADER_DIV, HEADER_DIV_ALT):
       break  # end of header
-    elif not header and 'node_id=' in line:
+    elif not header and b'node_id=' in line:
       break  # version 1.0 doesn't have any headers
     if b'=' in line:

More information about the tor-commits mailing list