[tor-commits] [stem/master] Socket closures raise a ValueError in python 3
atagar at torproject.org
atagar at torproject.org
Sat Feb 2 18:20:49 UTC 2013
commit 1e2e6204eb8ba618e79c7bb1459e53e5154147fa
Author: Damian Johnson <atagar at torproject.org>
Date: Sun Jan 27 17:43:22 2013 -0800
Socket closures raise a ValueError in python 3
Evidently reading from a closed socket file raises a ValueError rather than
socket.error in python 3...
Exception in thread Tor Listener:
Traceback (most recent call last):
File "/usr/lib/python3.2/threading.py", line 736, in _bootstrap_inner
self.run()
File "/usr/lib/python3.2/threading.py", line 689, in run
self._target(*self._args, **self._kwargs)
File "stem/control.py", line 573, in _reader_loop
control_message = self._socket.recv()
File "stem/socket.py", line 114, in recv
return recv_message(socket_file)
File "stem/socket.py", line 467, in recv_message
line = control_file.readline()
File "/usr/lib/python3.2/socket.py", line 269, in readinto
self._checkClosed()
ValueError: I/O operation on closed file.
---
stem/socket.py | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/stem/socket.py b/stem/socket.py
index bb7f0fe..9d48bd5 100644
--- a/stem/socket.py
+++ b/stem/socket.py
@@ -472,9 +472,14 @@ def recv_message(control_file):
prefix = logging_prefix % "SocketClosed"
log.info(prefix + "socket file has been closed")
raise stem.SocketClosed("socket file has been closed")
- except socket.error, exc:
- # when disconnected we get...
- # socket.error: [Errno 107] Transport endpoint is not connected
+ except (socket.error, ValueError), exc:
+ # When disconnected we get...
+ #
+ # Python 2:
+ # socket.error: [Errno 107] Transport endpoint is not connected
+ #
+ # Python 3:
+ # ValueError: I/O operation on closed file.
prefix = logging_prefix % "SocketClosed"
log.info(prefix + "received exception \"%s\"" % exc)
More information about the tor-commits
mailing list