Skip to content

Commit

Permalink
fix py2 compat issues
Browse files Browse the repository at this point in the history
  • Loading branch information
lxyu committed Dec 22, 2015
1 parent a43edb3 commit 153a065
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
6 changes: 4 additions & 2 deletions tests/test_socket.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-

from __future__ import absolute_import, division

import os
import socket

Expand Down Expand Up @@ -93,8 +95,8 @@ def test_client_socket_close():
conn.read(1024)
assert "TSocket read 0 bytes" in e.value.message

# linger on with timeout 1
with pytest.raises(BrokenPipeError):
# linger on with timeout 1 will close the socket immediately
with pytest.raises(socket.error):
conn.write(b"world")

conn.close()
Expand Down
2 changes: 1 addition & 1 deletion thriftpy/tornado.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def read_frame(self):
'Read zero bytes from stream')
frame_length, = struct.unpack('!i', frame_header)
logger.debug('received frame header, frame length = %d',
frame_length)
frame_length)
frame = yield self._read_bytes(frame_length)
logger.debug('received frame payload: %r', frame)
raise gen.Return(frame)
Expand Down
2 changes: 1 addition & 1 deletion thriftpy/transport/socket.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from __future__ import absolute_import
from __future__ import absolute_import, division

import errno
import os
Expand Down
7 changes: 4 additions & 3 deletions thriftpy/transport/sslsocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, host, port, socket_family=socket.AF_INET,
The `host` must be the same with server if validate enabled.
"""
super().__init__(
super(TSSLSocket, self).__init__(
host=host, port=port, socket_family=socket_family,
connect_timeout=connect_timeout, socket_timeout=socket_timeout)

Expand Down Expand Up @@ -82,8 +82,9 @@ def __init__(self, host, port, socket_family=socket.AF_INET,
to persist SSLContext object. Caution it's easy to get wrong, only
use if you know what you're doing.
"""
super().__init__(host=host, port=port, socket_family=socket_family,
client_timeout=client_timeout, backlog=backlog)
super(TSSLServerSocket, self).__init__(
host=host, port=port, socket_family=socket_family,
client_timeout=client_timeout, backlog=backlog)

if ssl_context:
self.ssl_context = ssl_context
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ commands =
py.test {posargs}

[testenv:flake8]
basepython = python
basepython = python3.5
deps =
flake8 >=2.5
commands =
Expand Down

0 comments on commit 153a065

Please sign in to comment.