Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#17083 closed defect (fixed)

Downloading server descriptors crashes with a TypeError

Reported by: trodun Owned by: atagar
Priority: Medium Milestone:
Component: Archived/Stem Version:
Severity: Keywords: descriptor
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:


The crash happens randomly, it must be tested multiple times until it appears.

from stem.descriptor.remote import DescriptorDownloader

downloader = DescriptorDownloader(use_mirrors=True, timeout=120, retries=1,
Traceback (most recent call last):
  File "E:\dev\prs\main\", line 5, in <module>
  File "e:\dev\envs\py34_x86\Python\lib\site-packages\stem\descriptor\", line 293, in run
    return list(self._run(suppress))
  File "e:\dev\envs\py34_x86\Python\lib\site-packages\stem\descriptor\", line 304, in _run
    raise self.error
  File "e:\dev\envs\py34_x86\Python\lib\site-packages\stem\descriptor\", line 357, in _download_descriptors
    self.download_url = self._pick_url(use_authority)
  File "e:\dev\envs\py34_x86\Python\lib\site-packages\stem\descriptor\", line 347, in _pick_url
    authority = random.choice(filter(HAS_V3IDENT, get_authorities().values()))
  File "e:\dev\envs\py34_x86\Python\lib\", line 253, in choice
    i = self._randbelow(len(seq))
TypeError: object of type 'filter' has no len()

Child Tickets

Change History (2)

comment:1 Changed 5 years ago by atagar

Resolution: fixed
Status: newclosed

Great catch! This looks to be a difference in how python2 and python3 behaves...

Python 2.7:

>>> foo = filter(lambda x: x % 2 == 0, [1, 2, 3])
>>> foo
>>> type(foo)
<type 'list'>

Python 3.2:

>>> foo = filter(lambda x: x % 2 == 0, [1, 2, 3])
>>> foo
<filter object at 0xb6fd280c>
>>> type(foo)
<class 'filter'>

Pushed a fix, feel free to reopen if that doesn't do the trick.

comment:2 Changed 5 years ago by trodun

Works well, thanks a lot for the quick fix. \o/

Note: See TracTickets for help on using tickets.