diff options
author | lethliel <mstrigl@suse.de> | 2020-02-19 11:53:05 +0100 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2020-03-09 11:42:13 +0100 |
commit | d3a43ffe1bfe4c128d6ab7c390419dee68f4ca5a (patch) | |
tree | eedd1f53ebc166283d17934e1e20da865c403c28 | |
parent | a63ce2f5b98c21a2763c9d96105793a6aa3c4ce3 (diff) | |
download | m2crypto-d3a43ffe1bfe4c128d6ab7c390419dee68f4ca5a.tar.gz |
wrap SocketIO in io.Buffered* for makefile
In python3.8 the fp is wrapped in a Buffer.
SSL.Connection.makefile returns a socketIO which is no buffer.
SocketIO in 'r' mode:
use io.BufferedReader
SocketIO in 'rw' mode:
use io.BufferedRWPair
-rw-r--r-- | M2Crypto/SSL/Connection.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/M2Crypto/SSL/Connection.py b/M2Crypto/SSL/Connection.py index 7053aa6..01bb61c 100644 --- a/M2Crypto/SSL/Connection.py +++ b/M2Crypto/SSL/Connection.py @@ -12,6 +12,7 @@ Copyright 2008 Heikki Toivonen. All rights reserved. import logging import socket +import io from M2Crypto import BIO, Err, X509, m2, py27plus, six, util # noqa from M2Crypto.SSL import Checker, Context, timeout # noqa @@ -582,9 +583,12 @@ class Connection(object): return m2.ssl_set_cipher_list(self.ssl, cipher_list) def makefile(self, mode='rb', bufsize=-1): - # type: (AnyStr, int) -> socket._fileobject + # type: (AnyStr, int) -> Union[io.BufferedRWPair,io.BufferedReader] if six.PY3: - return socket.SocketIO(self, mode) + raw = socket.SocketIO(self, mode) + if 'rw' in mode: + return io.BufferedRWPair(raw, raw) + return io.BufferedReader(raw, io.DEFAULT_BUFFER_SIZE) else: return socket._fileobject(self, mode, bufsize) |