#29332 closed defect (fixed)

bandwidth_file.py test fails with TypeError in Python 3.5

Reported by: juga Owned by: atagar
Priority: Medium Milestone:
Component: Core Tor/Stem Version:
Severity: Normal Keywords: tor-bwauth
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

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.

Child Tickets

Change History (2)

comment:1 Changed 10 months ago by juga

I obtain similar errors when trying to obtain any of the attributes of a BandwidthFile instance.

comment:2 Changed 10 months ago by atagar

Resolution: fixed
Status: newclosed

Oops! I'm sorry about that juga, my bad. Fixed.

https://gitweb.torproject.org/stem.git/commit/?id=f1c6e30d

Note: See TracTickets for help on using tickets.