[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Making sure that the socket's file is writeable



commit 6219ed6e6c517e0ce7d25b5d54355ed85329615e
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun Jan 27 18:02:49 2013 -0800

    Making sure that the socket's file is writeable
    
    In python 2.x the socket.makefile() method *should* only be readable
    (according to the default argument) but I've been using it for write operations
    too all this time. In python 3.x doing this raises "io.UnsupportedOperation:
    not writable" so guess we gotta fix it now. :)
    
    ======================================================================
    ERROR: test_get_connections
    ----------------------------------------------------------------------
    Traceback:
      File "/home/atagar/Desktop/stem/test/data/python3/test/integ/util/proc.py", line 92, in test_get_connections
        elif not test.runner.get_runner().is_ptraceable():
      File "/home/atagar/Desktop/stem/test/data/python3/test/runner.py", line 413, in is_ptraceable
        tor_version = self.get_tor_version()
      File "/home/atagar/Desktop/stem/test/data/python3/test/runner.py", line 567, in get_tor_version
        control_socket = self.get_tor_socket()
      File "/home/atagar/Desktop/stem/test/data/python3/test/runner.py", line 534, in get_tor_socket
        stem.connection.authenticate(control_socket, CONTROL_PASSWORD, self.get_chroot())
      File "/home/atagar/Desktop/stem/test/data/python3/stem/connection.py", line 321, in authenticate
        protocolinfo_response = get_protocolinfo(controller)
      File "/home/atagar/Desktop/stem/test/data/python3/stem/connection.py", line 800, in get_protocolinfo
        protocolinfo_response = _msg(controller, "PROTOCOLINFO 1")
      File "/home/atagar/Desktop/stem/test/data/python3/stem/connection.py", line 836, in _msg
        controller.send(message)
      File "/home/atagar/Desktop/stem/test/data/python3/stem/socket.py", line 82, in send
        send_message(self._socket_file, message, raw)
      File "/home/atagar/Desktop/stem/test/data/python3/stem/socket.py", line 422, in send_message
        control_file.write(message)
    io.UnsupportedOperation: not writable
---
 stem/socket.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/stem/socket.py b/stem/socket.py
index 9d48bd5..cad4572 100644
--- a/stem/socket.py
+++ b/stem/socket.py
@@ -181,7 +181,7 @@ class ControlSocket(object):
 
       with self._recv_lock:
         self._socket = self._make_socket()
-        self._socket_file = self._socket.makefile()
+        self._socket_file = self._socket.makefile(mode = "rw")
         self._is_alive = True
 
         # It's possible for this to have a transient failure...



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits