erdiaker / torrequest

Simple Python interface for HTTP(s) requests over Tor
235 stars 42 forks source link

README examples broken in python 3.8 #10

Closed CorruptCommit closed 4 years ago

CorruptCommit commented 5 years ago

With the recent update to python 3.8, the examples on the README no loner work.

pipenv run python --version
Python 3.8.0
pipenv run python TorRequest-example-short.py
Traceback (most recent call last):
  File "TorRequest-example-short.py", line 3, in <module>
    with TorRequest() as tr:
  File "/home/user/.local/share/virtualenvs/gitlab-build-status-iwiHKajp/lib/python3.8/site-packages/torrequest.py", line 24, in __init__
    self.ctrl.authenticate(password=password)
  File "/home/user/.local/share/virtualenvs/gitlab-build-status-iwiHKajp/lib/python3.8/site-packages/stem/control.py", line 1100, in authenticate
    stem.connection.authenticate(self, *args, **kwargs)
  File "/home/user/.local/share/virtualenvs/gitlab-build-status-iwiHKajp/lib/python3.8/site-packages/stem/connection.py", line 592, in authenticate
    controller._post_authentication()
  File "/home/user/.local/share/virtualenvs/gitlab-build-status-iwiHKajp/lib/python3.8/site-packages/stem/control.py", line 3902, in _post_authentication
    owning_pid = self.get_conf('__OwningControllerProcess', None)
  File "/home/user/.local/share/virtualenvs/gitlab-build-status-iwiHKajp/lib/python3.8/site-packages/stem/control.py", line 2170, in get_conf
    entries = self.get_conf_map(param, default, multiple)
  File "/home/user/.local/share/virtualenvs/gitlab-build-status-iwiHKajp/lib/python3.8/site-packages/stem/control.py", line 2273, in get_conf_map
    for key in reply:
RuntimeError: dictionary keys changed during iteration

The longer example has an extra ' at the end of line 17 (look for data and auth). Once the syntax is corrected, here is the same error:

pipenv run python TorRequest-example-long.py
Traceback (most recent call last):
  File "TorRequest-example-long.py", line 9, in <module>
    with TorRequest(proxy_port=9050, ctrl_port=9051, password=None) as tr:
  File "/home/user/.local/share/virtualenvs/gitlab-build-status-iwiHKajp/lib/python3.8/site-packages/torrequest.py", line 24, in __init__
    self.ctrl.authenticate(password=password)
  File "/home/user/.local/share/virtualenvs/gitlab-build-status-iwiHKajp/lib/python3.8/site-packages/stem/control.py", line 1100, in authenticate
    stem.connection.authenticate(self, *args, **kwargs)
  File "/home/user/.local/share/virtualenvs/gitlab-build-status-iwiHKajp/lib/python3.8/site-packages/stem/connection.py", line 592, in authenticate
    controller._post_authentication()
  File "/home/user/.local/share/virtualenvs/gitlab-build-status-iwiHKajp/lib/python3.8/site-packages/stem/control.py", line 3902, in _post_authentication
    owning_pid = self.get_conf('__OwningControllerProcess', None)
  File "/home/user/.local/share/virtualenvs/gitlab-build-status-iwiHKajp/lib/python3.8/site-packages/stem/control.py", line 2170, in get_conf
    entries = self.get_conf_map(param, default, multiple)
  File "/home/user/.local/share/virtualenvs/gitlab-build-status-iwiHKajp/lib/python3.8/site-packages/stem/control.py", line 2273, in get_conf_map
    for key in reply:
RuntimeError: dictionary keys changed during iteration
CorruptCommit commented 5 years ago

Looks to be a bug with stem, see this ticket.

CorruptCommit commented 4 years ago

Now that stem 1.8.0 has been released, this issue has been corrected.