Skip to content

Commit a1428a3

Browse files
committed
Re-introduce support for Python < 2.7.9
42bfde0 introduced a change that relied on an Exception class (ssl.SSLWantReadError) present only in modern Python versions. This changes that to work exactly the same way, only in a way that works for older Python versions also.
1 parent 42bfde0 commit a1428a3

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

slackclient/_server.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from slackclient._channel import Channel
33
from slackclient._user import User
44
from slackclient._util import SearchList
5-
from ssl import SSLWantReadError
5+
from ssl import SSLError
66

77
from websocket import create_connection
88
import json
@@ -107,8 +107,16 @@ def websocket_safe_read(self):
107107
while True:
108108
try:
109109
data += "{}\n".format(self.websocket.recv())
110-
except SSLWantReadError:
111-
return ''
110+
except SSLError as e:
111+
if e.errno == 2:
112+
# errno 2 occurs when trying to read or write data, but more
113+
# data needs to be received on the underlying TCP transport
114+
# before the request can be fulfilled.
115+
#
116+
# Python 2.7.9+ and Python 3.3+ give this its own exception,
117+
# SSLWantReadError
118+
return ''
119+
raise
112120
return data.rstrip()
113121

114122
def attach_user(self, name, id, real_name, tz):

0 commit comments

Comments
 (0)