[tor-bugs] #29332 [Core Tor/Stem]: bandwidth_file.py test fails with TypeError in Python 3.5

Tor Bug Tracker & Wiki blackhole at torproject.org
Tue Feb 5 09:01:15 UTC 2019


#29332: bandwidth_file.py test fails with TypeError in Python 3.5
-------------------------------+------------------------
     Reporter:  juga           |      Owner:  atagar
         Type:  defect         |     Status:  new
     Priority:  Medium         |  Milestone:
    Component:  Core Tor/Stem  |    Version:
     Severity:  Normal         |   Keywords:  tor-bwauth
Actual Points:                 |  Parent ID:
       Points:                 |   Reviewer:
      Sponsor:                 |
-------------------------------+------------------------
 When `pytest test/unit/descriptor/bandwidth_file.py` is run in a Python
 3.5 environment, it fails with the error:
 {{{
 descriptor = <stem.descriptor.bandwidth_file.BandwidthFile object at
 0x7f6a8c41b9b0>, entries = None

     def _parse_header(descriptor, entries):
       header = OrderedDict()
       content = io.BytesIO(descriptor.get_bytes())

       content.readline()  # skip the first line, which should be the
 timestamp

       while True:
         line = content.readline().strip()

         if not line:
           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:
 E       TypeError: a bytes-like object is required, not 'str'

 stem/descriptor/bandwidth_file.py:116: TypeError
 }}}

 It seems something is missing with the bytes/str python 2/3 compatibility.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/29332>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list