Commit 43c9a04c authored by Denis Bilenko's avatar Denis Bilenko

socket: improve converting SSL.Error to sslerror

parent 43cc056e
...@@ -250,6 +250,9 @@ class GreenSocket(object): ...@@ -250,6 +250,9 @@ class GreenSocket(object):
return self.timeout return self.timeout
SysCallError_code_mapping = {-1: 8}
class GreenSSL(GreenSocket): class GreenSSL(GreenSocket):
is_secure = True is_secure = True
...@@ -297,7 +300,8 @@ class GreenSSL(GreenSocket): ...@@ -297,7 +300,8 @@ class GreenSSL(GreenSocket):
except SSL.WantWriteError: except SSL.WantWriteError:
wait_writer(self.fileno()) wait_writer(self.fileno())
except SSL.SysCallError, ex: except SSL.SysCallError, ex:
# XXX fix ex[0] raise sslerror(SysCallError_code_mapping.get(ex.args[0], ex.args[0]), ex.args[1])
except SSL.Error, ex:
raise sslerror(str(ex)) raise sslerror(str(ex))
def connect(self, *args): def connect(self, *args):
...@@ -332,7 +336,10 @@ class GreenSSL(GreenSocket): ...@@ -332,7 +336,10 @@ class GreenSSL(GreenSocket):
except SSL.SysCallError, e: except SSL.SysCallError, e:
if e[0] == -1 or e[0] > 0: if e[0] == -1 or e[0] > 0:
return '' return ''
raise sslerror(str(e)) except SSL.SysCallError, ex:
raise sslerror(SysCallError_code_mapping.get(ex.args[0], ex.args[0]), ex.args[1])
except SSL.Error, ex:
raise sslerror(str(ex))
# NOTE: read() in SSLObject does not have the semantics of file.read # NOTE: read() in SSLObject does not have the semantics of file.read
# reading here until we have buflen bytes or hit EOF is an error # reading here until we have buflen bytes or hit EOF is an error
......
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