[Python-modules-team] Bug#901772: python-eventlet: Cherry pick of fix for recursion issue with ssl module under Python 3.6

James Page james.page at ubuntu.com
Mon Jun 18 09:09:56 BST 2018


Package: python-eventlet
Version: 0.20.0-4
Severity: normal
Tags: patch
User: ubuntu-devel at lists.ubuntu.com
Usertags: origin-ubuntu cosmic ubuntu-patch

Dear Maintainer,

In Ubuntu, the attached patch was applied to achieve the following:

  * d/p/py36-ssl-compat.patch: Cherry pick fix for recursion issue
    with ssl module under Python 3.6.

Thanks for considering the patch.


-- System Information:
Debian Release: buster/sid
  APT prefers cosmic
  APT policy: (500, 'cosmic')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.15.0-22-generic (SMP w/4 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE=en_GB:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
-------------- next part --------------
diff -Nru python-eventlet-0.20.0/debian/patches/py36-ssl-compat.patch python-eventlet-0.20.0/debian/patches/py36-ssl-compat.patch
--- python-eventlet-0.20.0/debian/patches/py36-ssl-compat.patch	1970-01-01 01:00:00.000000000 +0100
+++ python-eventlet-0.20.0/debian/patches/py36-ssl-compat.patch	2018-06-15 14:41:09.000000000 +0100
@@ -0,0 +1,66 @@
+From de06878e5a295bfbbddca0048c3453d16168a676 Mon Sep 17 00:00:00 2001
+From: Sergey Shepelev <temotor at gmail.com>
+Date: Tue, 4 Apr 2017 17:31:22 +0300
+Subject: [PATCH] ssl: RecursionError on Python3.6+; Thanks to
+ justdoit0823 at github and Gevent developers
+
+https://github.com/eventlet/eventlet/issues/371
+---
+ eventlet/green/ssl.py                       | 20 ++++++++++++++++++++
+ tests/isolated/green_ssl_py36_properties.py | 16 ++++++++++++++++
+ 2 files changed, 36 insertions(+)
+ create mode 100644 tests/isolated/green_ssl_py36_properties.py
+
+diff --git a/eventlet/green/ssl.py b/eventlet/green/ssl.py
+index d7fbef7e..a5a20627 100644
+--- a/eventlet/green/ssl.py
++++ b/eventlet/green/ssl.py
+@@ -401,6 +401,26 @@ class GreenSSLContext(_original_sslcontext):
+         def wrap_socket(self, sock, *a, **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
+ 
+     if hasattr(__ssl, 'create_default_context'):
+diff --git a/tests/isolated/green_ssl_py36_properties.py b/tests/isolated/green_ssl_py36_properties.py
+new file mode 100644
+index 00000000..aa6b5b5a
+--- /dev/null
++++ b/tests/isolated/green_ssl_py36_properties.py
+@@ -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')
diff -Nru python-eventlet-0.20.0/debian/patches/series python-eventlet-0.20.0/debian/patches/series
--- python-eventlet-0.20.0/debian/patches/series	2017-12-01 12:02:18.000000000 +0000
+++ python-eventlet-0.20.0/debian/patches/series	2018-06-15 14:41:22.000000000 +0100
@@ -9,3 +9,5 @@
 0009-Removed-test_urllib-that-is-failing-in-py36.patch
 0010-Fix-compilation-errors-when-installing-package-in-Py.patch
 0011-Avoid-dependency-on-enum-compat.patch
+# Ubuntu
+py36-ssl-compat.patch


More information about the Python-modules-team mailing list