Commit 0911fe3e authored by Fantix King's avatar Fantix King

Fix indexing exceptions (ex[0]) by using args (ex.args[0]), refs #38

parent b48db7d1
......@@ -15,7 +15,7 @@ def gevent_sendfile(out_fd, in_fd, offset, count):
#print('%s: sent %s [%d%%]' % (out_fd, sent, 100*total_sent/count))
total_sent += sent
except OSError as ex:
if ex[0] == EAGAIN:
if ex.args[0] == EAGAIN:
wait_write(out_fd)
else:
raise
......
......@@ -284,7 +284,7 @@ class BaseServer(object):
Greenlet.spawn(self.stop, timeout=stop_timeout).join()
def is_fatal_error(self, ex):
return isinstance(ex, _socket.error) and ex[0] in self.fatal_errors
return isinstance(ex, _socket.error) and ex.args[0] in self.fatal_errors
def _extract_family(host):
......
......@@ -92,7 +92,7 @@ class StreamServer(BaseServer):
try:
client_socket, address = self.socket.accept()
except _socket.error as err:
if err[0] == EWOULDBLOCK:
if err.args[0] == EWOULDBLOCK:
return
raise
return socket(_sock=client_socket), address
......@@ -131,7 +131,7 @@ class DatagramServer(BaseServer):
try:
data, address = self._socket.recvfrom(8192)
except _socket.error as err:
if err[0] == EWOULDBLOCK:
if err.args[0] == EWOULDBLOCK:
return
raise
return data, address
......
......@@ -303,7 +303,7 @@ class socket(object):
client_socket, address = sock.accept()
break
except error as ex:
if ex[0] != EWOULDBLOCK or self.timeout == 0.0:
if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0:
raise
sys.exc_clear()
self._wait(self._read_event)
......
......@@ -71,7 +71,7 @@ class SSLSocket(socket):
try:
socket.getpeername(self)
except socket_error as e:
if e[0] != errno.ENOTCONN:
if e.args[0] != errno.ENOTCONN:
raise
# no, no connection yet
self._sslobj = None
......
......@@ -12,7 +12,7 @@ class TestClosedSocket(greentest.TestCase):
try:
sock.send('a', timeout=1)
except socket.error as ex:
if ex[0] != 9:
if ex.args[0] != 9:
raise
......
......@@ -31,7 +31,6 @@ class Test(greentest.TestCase):
except socket.error as ex:
self.assertEqual(ex.args, ('timed out',))
self.assertEqual(str(ex), 'timed out')
self.assertEqual(ex[0], 'timed out')
finally:
sock.close()
finally:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment