ssl: RecursionError on Python3.6+; Thanks to justdoit0823@github and Gevent developers
https://github.com/eventlet/eventlet/issues/371
This commit is contained in:
@@ -401,6 +401,26 @@ if hasattr(__ssl, 'SSLContext'):
|
|||||||
def wrap_socket(self, sock, *a, **kw):
|
def wrap_socket(self, sock, *a, **kw):
|
||||||
return GreenSSLSocket(sock, *a, _context=self, **kw)
|
return GreenSSLSocket(sock, *a, _context=self, **kw)
|
||||||
|
|
||||||
|
# https://github.com/eventlet/eventlet/issues/371
|
||||||
|
# Thanks to Gevent developers for sharing patch to this problem.
|
||||||
|
if hasattr(_original_sslcontext.options, 'setter'):
|
||||||
|
# In 3.6, these became properties. They want to access the
|
||||||
|
# property __set__ method in the superclass, and they do so by using
|
||||||
|
# super(SSLContext, SSLContext). But we rebind SSLContext when we monkey
|
||||||
|
# patch, which causes infinite recursion.
|
||||||
|
# https://github.com/python/cpython/commit/328067c468f82e4ec1b5c510a4e84509e010f296
|
||||||
|
@_original_sslcontext.options.setter
|
||||||
|
def options(self, value):
|
||||||
|
super(_original_sslcontext, _original_sslcontext).options.__set__(self, value)
|
||||||
|
|
||||||
|
@_original_sslcontext.verify_flags.setter
|
||||||
|
def verify_flags(self, value):
|
||||||
|
super(_original_sslcontext, _original_sslcontext).verify_flags.__set__(self, value)
|
||||||
|
|
||||||
|
@_original_sslcontext.verify_mode.setter
|
||||||
|
def verify_mode(self, value):
|
||||||
|
super(_original_sslcontext, _original_sslcontext).verify_mode.__set__(self, value)
|
||||||
|
|
||||||
SSLContext = GreenSSLContext
|
SSLContext = GreenSSLContext
|
||||||
|
|
||||||
if hasattr(__ssl, 'create_default_context'):
|
if hasattr(__ssl, 'create_default_context'):
|
||||||
|
16
tests/isolated/green_ssl_py36_properties.py
Normal file
16
tests/isolated/green_ssl_py36_properties.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
__test__ = False
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
import eventlet
|
||||||
|
eventlet.monkey_patch()
|
||||||
|
|
||||||
|
try:
|
||||||
|
eventlet.wrap_ssl(
|
||||||
|
eventlet.listen(('localhost', 0)),
|
||||||
|
certfile='does-not-exist',
|
||||||
|
keyfile='does-not-exist',
|
||||||
|
server_side=True)
|
||||||
|
except IOError as ex:
|
||||||
|
assert ex.errno == 2
|
||||||
|
print('pass')
|
Reference in New Issue
Block a user