[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Stacktrace if stem.connection.connect gets a string port argument
commit 3be0f86825d2be1d840b5667aa86a1b6176ab70d
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Sun Dec 17 15:07:17 2017 -0800
Stacktrace if stem.connection.connect gets a string port argument
Oops. When we present a string rather than int for a port argument we
stacktrace. Caught while looking into ways we can improve a script by
toralf.
Traceback (most recent call last):
File "info.py", line 191, in <module>
main()
File "info.py", line 57, in main
with stem.connection.connect(control_port = ('127.0.0.1', control_port)) as controller:
File "/home/atagar/Desktop/tor/tor-utils/stem/connection.py", line 277, in connect
control_connection = stem.socket.ControlPort(address, port)
File "/home/atagar/Desktop/tor/tor-utils/stem/socket.py", line 376, in __init__
self.connect()
File "/home/atagar/Desktop/tor/tor-utils/stem/socket.py", line 247, in connect
self._socket = self._make_socket()
File "/home/atagar/Desktop/tor/tor-utils/stem/socket.py", line 402, in _make_socket
control_socket.connect((self._control_addr, self._control_port))
File "/usr/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
TypeError: an integer is required
---
docs/change_log.rst | 1 +
stem/connection.py | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/docs/change_log.rst b/docs/change_log.rst
index cfe5200e..13597155 100644
--- a/docs/change_log.rst
+++ b/docs/change_log.rst
@@ -47,6 +47,7 @@ The following are only available within Stem's `git repository
* **Controller**
* Added support for limiting the maximum number of streams to :func:`~stem.control.Controller.create_ephemeral_hidden_service` (:spec:`2fcb1c2`)
+ * Stacktrace if :func:`stem.connection.connect` had a string port argument
.. _version_1.6:
diff --git a/stem/connection.py b/stem/connection.py
index 62309f0b..3aad575a 100644
--- a/stem/connection.py
+++ b/stem/connection.py
@@ -272,7 +272,7 @@ def connect(control_port = ('127.0.0.1', 'default'), control_socket = '/var/run/
if port == 'default':
control_connection = _connection_for_default_port(address)
else:
- control_connection = stem.socket.ControlPort(address, port)
+ control_connection = stem.socket.ControlPort(address, int(port))
except stem.SocketError as exc:
error_msg = CONNECT_MESSAGES['unable_to_use_port'].format(address = address, port = port, error = exc)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits