python-M2Crypto/001-fix-buffering-for-python38.patch
Matej Cepl cc5d0523fe Accepting request 782869 from home:mstrigl:branches:devel:languages:python
- in python3.8 the fp is wrapped in a Buffer. SSL.Connection.makefile 
  returns a socketIO which is no buffer.
  Added: 001-fix-buffering-for-python38.patch

OBS-URL: https://build.opensuse.org/request/show/782869
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-M2Crypto?expand=0&rev=86
2020-03-09 10:09:18 +00:00

25 lines
902 B
Diff

diff --git a/M2Crypto/SSL/Connection.py b/M2Crypto/SSL/Connection.py
index 7053aa6..6503935 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
@@ -584,7 +585,10 @@ class Connection(object):
def makefile(self, mode='rb', bufsize=-1):
# type: (AnyStr, int) -> socket._fileobject
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)