diff --git a/0001-Python-3.10-partial-support.patch b/0001-Python-3.10-partial-support.patch new file mode 100644 index 0000000000000000000000000000000000000000..ef6ef0a3b1dd8b1b9ecbc1fe9716e1a271b2d884 --- /dev/null +++ b/0001-Python-3.10-partial-support.patch @@ -0,0 +1,118 @@ +From 15d3c2477510229e1b49c60fccfde5ffe94b2a76 Mon Sep 17 00:00:00 2001 +From: Tim Burke +Date: Fri, 8 Oct 2021 03:18:04 -0700 +Subject: [PATCH] Python 3.10 partial support + +Everything below is specific to changes in Python 3.10. +https://github.com/eventlet/eventlet/pull/715 + +- Only wrap socket.timeout on Python < 3.10 + socket.timeout is TimeoutError, which our is_timeout() helper func already knows. + fixes https://github.com/eventlet/eventlet/issues/687 +- Working greenio._open + _pyio.open is now a staticmethod, so we've got to go down to + _pyio.open.__wrapped__ to get to the python function object. +- Test using eventlet.is_timeout rather than requiring an is_timeout attribute on errors. + TimeoutErrors (which are covered by is_timeout) can't necessarily have attributes added to them. +- Fix backdoor tests + Skip build info line at interpreter startup. Also, start printing the banner as we read it to aid in future debugging. +- Tolerate __builtins__ being a dict (rather than module) in is_timeout + (@tipabu) still not sure how this happens, but somehow it does in socket_test.test_error_is_timeout. +--- + eventlet/greenio/base.py | 5 ++++- + eventlet/greenio/py3.py | 5 ++++- + eventlet/timeout.py | 9 +++++++-- + tests/__init__.py | 2 +- + tests/backdoor_test.py | 5 ++++- + 5 files changed, 20 insertions(+), 6 deletions(-) + +diff --git a/eventlet/greenio/base.py b/eventlet/greenio/base.py +index 2eed8696..51a7ae13 100644 +--- a/eventlet/greenio/base.py ++++ b/eventlet/greenio/base.py +@@ -29,7 +29,10 @@ if six.PY2: + _original_socket = eventlet.patcher.original('socket').socket + + +-socket_timeout = eventlet.timeout.wrap_is_timeout(socket.timeout) ++if sys.version_info >= (3, 10): ++ socket_timeout = socket.timeout # Really, TimeoutError ++else: ++ socket_timeout = eventlet.timeout.wrap_is_timeout(socket.timeout) + + + def socket_connect(descriptor, address): +diff --git a/eventlet/greenio/py3.py b/eventlet/greenio/py3.py +index 7a75b52c..bc3dc949 100644 +--- a/eventlet/greenio/py3.py ++++ b/eventlet/greenio/py3.py +@@ -191,9 +191,12 @@ _open_environment.update(dict( + FileIO=GreenFileIO, + os=_original_os, + )) ++if hasattr(_original_pyio, 'text_encoding'): ++ _open_environment['text_encoding'] = _original_pyio.text_encoding + ++_pyio_open = getattr(_original_pyio.open, '__wrapped__', _original_pyio.open) + _open = FunctionType( +- six.get_function_code(_original_pyio.open), ++ six.get_function_code(_pyio_open), + _open_environment, + ) + +diff --git a/eventlet/timeout.py b/eventlet/timeout.py +index 6e1e08f6..4ab893ee 100644 +--- a/eventlet/timeout.py ++++ b/eventlet/timeout.py +@@ -174,6 +174,11 @@ def wrap_is_timeout(base): + return fun + + ++if isinstance(__builtins__, dict): # seen when running tests on py310, but HOW?? ++ _timeout_err = __builtins__.get('TimeoutError', Timeout) ++else: ++ _timeout_err = getattr(__builtins__, 'TimeoutError', Timeout) ++ ++ + def is_timeout(obj): +- py3err = getattr(__builtins__, 'TimeoutError', Timeout) +- return bool(getattr(obj, 'is_timeout', False)) or isinstance(obj, py3err) ++ return bool(getattr(obj, 'is_timeout', False)) or isinstance(obj, _timeout_err) +diff --git a/tests/__init__.py b/tests/__init__.py +index c0b64fd9..18836677 100644 +--- a/tests/__init__.py ++++ b/tests/__init__.py +@@ -383,7 +383,7 @@ def run_isolated(path, prefix='tests/isolated/', **kwargs): + + def check_is_timeout(obj): + value_text = getattr(obj, 'is_timeout', '(missing)') +- assert obj.is_timeout, 'type={0} str={1} .is_timeout={2}'.format(type(obj), str(obj), value_text) ++ assert eventlet.is_timeout(obj), 'type={0} str={1} .is_timeout={2}'.format(type(obj), str(obj), value_text) + + + @contextlib.contextmanager +diff --git a/tests/backdoor_test.py b/tests/backdoor_test.py +index 03a56925..1e09f09b 100644 +--- a/tests/backdoor_test.py ++++ b/tests/backdoor_test.py +@@ -1,5 +1,6 @@ + import os + import os.path ++import sys + + import eventlet + +@@ -22,7 +23,9 @@ class BackdoorTest(tests.LimitedTestCase): + def _run_test_on_client_and_server(self, client, server_thread): + f = client.makefile('rw') + assert 'Python' in f.readline() +- f.readline() # build info ++ if sys.version_info < (3, 10): ++ # Starting in py310, build info is included in version line ++ f.readline() # build info + f.readline() # help info + assert 'InteractiveConsole' in f.readline() + self.assertEqual('>>> ', f.read(4)) +-- +2.37.2.windows.2 + diff --git a/python-eventlet.spec b/python-eventlet.spec index cb5812909b084d493c1a4ecac01fc61d97b79398..f7ba88c7190827e39617c7a08634337d6e4a1047 100644 --- a/python-eventlet.spec +++ b/python-eventlet.spec @@ -1,11 +1,12 @@ %global _empty_manifest_terminate_build 0 Name: python-eventlet Version: 0.30.2 -Release: 1 +Release: 2 Summary: Highly concurrent networking library License: MIT License URL: http://eventlet.net Source0: https://files.pythonhosted.org/packages/23/db/8ff5a9dec5ff016d5836254b676d507c2180d8838d7e545277d938896913/eventlet-0.30.2.tar.gz +Patch0: 0001-Python-3.10-partial-support.patch BuildArch: noarch %description @@ -40,7 +41,7 @@ Provides: python3-eventlet-doc Eventlet is a concurrent networking library for Python that allows you to change how you run your code, not how you write it. %prep -%autosetup -n eventlet-0.30.2 -S git +%autosetup -n eventlet-0.30.2 -S git -p1 %build %py3_build @@ -83,6 +84,9 @@ mv %{buildroot}/doclist.lst . %{_docdir}/* %changelog +* Fri Apr 26 2024 yanjianqing - 0.30.2-2 +- Only wrap socket.timeout on Python < 3.10 + * Mon Jul 26 2021 OpenStack_SIG - 0.30.2-1 - update to 0.30.2 diff --git a/python37.patch b/python37.patch deleted file mode 100644 index 62816babd721b1f353b0fdd28fb0b2ca10a5bdb1..0000000000000000000000000000000000000000 --- a/python37.patch +++ /dev/null @@ -1,140 +0,0 @@ -From 0d4e7bcb90800d6700b2c81c41c9770ee5f94358 Mon Sep 17 00:00:00 2001 -From: Marcel Plch -Date: Mon, 9 Jul 2018 16:45:45 +0200 -Subject: [PATCH] Fix for Python 3.7 - ---- - eventlet/green/ssl.py | 46 ++++++++++++++++++++++++++++++++++++++++------ - tests/debug_test.py | 14 ++++++++++++-- - tests/hub_test.py | 4 +++- - 3 files changed, 55 insertions(+), 9 deletions(-) - -diff --git a/eventlet/green/ssl.py b/eventlet/green/ssl.py -index 53ee9a3c..df72869e 100644 ---- a/eventlet/green/ssl.py -+++ b/eventlet/green/ssl.py -@@ -24,6 +24,7 @@ - 'create_default_context', '_create_default_https_context'] - - _original_sslsocket = __ssl.SSLSocket -+_original_wrap_socket = __ssl.wrap_socket - - - class GreenSSLSocket(_original_sslsocket): -@@ -57,11 +58,41 @@ def __init__(self, sock, keyfile=None, certfile=None, - # this assignment - self._timeout = sock.gettimeout() - -- # nonblocking socket handshaking on connect got disabled so let's pretend it's disabled -- # even when it's on -- super(GreenSSLSocket, self).__init__( -- sock.fd, keyfile, certfile, server_side, cert_reqs, ssl_version, -- ca_certs, do_handshake_on_connect and six.PY2, *args, **kw) -+ if sys.version_info >= (3, 7): -+ # Monkey-patch the sslsocket so our modified self gets -+ # injected into its _create method. -+ def fake_new(self, cls, *args, **kwargs): -+ return self -+ -+ orig_new = _original_sslsocket.__new__ -+ try: -+ _original_sslsocket.__new__ = fake_new.__get__(self, GreenSSLSocket) -+ -+ self = _original_wrap_socket( -+ sock=sock.fd, -+ keyfile=keyfile, -+ certfile=certfile, -+ server_side=server_side, -+ cert_reqs=cert_reqs, -+ ssl_version=ssl_version, -+ ca_certs=ca_certs, -+ do_handshake_on_connect=do_handshake_on_connect and six.PY2, -+ *args, **kw -+ ) -+ self.keyfile = keyfile -+ self.certfile = certfile -+ self.cert_reqs = cert_reqs -+ self.ssl_version = ssl_version -+ self.ca_certs = ca_certs -+ finally: -+ # Unpatch -+ _original_sslsocket.__new__ = orig_new -+ else: -+ # nonblocking socket handshaking on connect got disabled so let's pretend it's disabled -+ # even when it's on -+ super(GreenSSLSocket, self).__init__( -+ sock.fd, keyfile, certfile, server_side, cert_reqs, ssl_version, -+ ca_certs, do_handshake_on_connect and six.PY2, *args, **kw) - - # the superclass initializer trashes the methods so we remove - # the local-object versions of them and let the actual class -@@ -323,7 +354,10 @@ def connect(self, addr): - except NameError: - self._sslobj = sslobj - else: -- self._sslobj = SSLObject(sslobj, owner=self) -+ if sys.version_info < (3, 7): -+ self._sslobj = SSLObject(sslobj, owner=self) -+ else: -+ self._sslobj = sslobj - - if self.do_handshake_on_connect: - self.do_handshake() -diff --git a/tests/debug_test.py b/tests/debug_test.py -index 8299dede..82b3a834 100644 ---- a/tests/debug_test.py -+++ b/tests/debug_test.py -@@ -29,6 +29,11 @@ def test_unspew(self): - assert self.tracer is None - - def test_line(self): -+ if sys.version_info >= (3, 7): -+ frame_str = "f== (3, 7): -+ frame_str = "f=