|
rdobuilder |
455d87 |
From 3fde87d6af97551ce9e18ad8835947153530e121 Mon Sep 17 00:00:00 2001
|
|
|
f9c8e3 |
From: Tim Burke <tim.burke@gmail.com>
|
|
|
f9c8e3 |
Date: Wed, 9 Jun 2021 14:40:13 -0700
|
|
rdobuilder |
455d87 |
Subject: [PATCH 1/5] Only wrap socket.timeout on Python < 3.10
|
|
|
f9c8e3 |
|
|
|
f9c8e3 |
On py310, socket.timeout is TimeoutError, which our is_timeout() helper
|
|
|
f9c8e3 |
func already knows is a timeout.
|
|
|
f9c8e3 |
|
|
|
f9c8e3 |
Note that this doesn't get us to py310 support (not by a long shot), but
|
|
|
f9c8e3 |
it's a step along the way.
|
|
|
f9c8e3 |
|
|
|
f9c8e3 |
Closes #687
|
|
|
f9c8e3 |
---
|
|
|
f9c8e3 |
eventlet/greenio/base.py | 5 ++++-
|
|
|
f9c8e3 |
1 file changed, 4 insertions(+), 1 deletion(-)
|
|
|
f9c8e3 |
|
|
|
f9c8e3 |
diff --git a/eventlet/greenio/base.py b/eventlet/greenio/base.py
|
|
|
f9c8e3 |
index 2eed86966..51a7ae13e 100644
|
|
|
f9c8e3 |
--- a/eventlet/greenio/base.py
|
|
|
f9c8e3 |
+++ b/eventlet/greenio/base.py
|
|
|
f9c8e3 |
@@ -29,7 +29,10 @@
|
|
|
f9c8e3 |
_original_socket = eventlet.patcher.original('socket').socket
|
|
|
f9c8e3 |
|
|
|
f9c8e3 |
|
|
|
f9c8e3 |
-socket_timeout = eventlet.timeout.wrap_is_timeout(socket.timeout)
|
|
|
f9c8e3 |
+if sys.version_info >= (3, 10):
|
|
|
f9c8e3 |
+ socket_timeout = socket.timeout # Really, TimeoutError
|
|
|
f9c8e3 |
+else:
|
|
|
f9c8e3 |
+ socket_timeout = eventlet.timeout.wrap_is_timeout(socket.timeout)
|
|
|
f9c8e3 |
|
|
|
f9c8e3 |
|
|
|
f9c8e3 |
def socket_connect(descriptor, address):
|
|
|
f9c8e3 |
|
|
rdobuilder |
455d87 |
From ccf6db2df4edd1a7dda671515df20edd846a7f53 Mon Sep 17 00:00:00 2001
|
|
|
f9c8e3 |
From: Tim Burke <tim.burke@gmail.com>
|
|
|
f9c8e3 |
Date: Fri, 11 Jun 2021 12:56:07 -0700
|
|
rdobuilder |
455d87 |
Subject: [PATCH 2/5] Get a working greenio._open on py310
|
|
|
f9c8e3 |
|
|
rdobuilder |
455d87 |
_pyio.open is now a staticmethod, so we've got to go down to
|
|
rdobuilder |
455d87 |
_pyio.open.__wrapped__ to get to the python function object.
|
|
|
f9c8e3 |
---
|
|
rdobuilder |
455d87 |
eventlet/greenio/py3.py | 5 ++++-
|
|
rdobuilder |
455d87 |
1 file changed, 4 insertions(+), 1 deletion(-)
|
|
|
f9c8e3 |
|
|
|
f9c8e3 |
diff --git a/eventlet/greenio/py3.py b/eventlet/greenio/py3.py
|
|
rdobuilder |
455d87 |
index 7a75b52c0..bc3dc9499 100644
|
|
|
f9c8e3 |
--- a/eventlet/greenio/py3.py
|
|
|
f9c8e3 |
+++ b/eventlet/greenio/py3.py
|
|
rdobuilder |
455d87 |
@@ -191,9 +191,12 @@ def __exit__(self, *args):
|
|
|
f9c8e3 |
FileIO=GreenFileIO,
|
|
|
f9c8e3 |
os=_original_os,
|
|
rdobuilder |
455d87 |
))
|
|
rdobuilder |
455d87 |
+if hasattr(_original_pyio, 'text_encoding'):
|
|
rdobuilder |
455d87 |
+ _open_environment['text_encoding'] = _original_pyio.text_encoding
|
|
rdobuilder |
455d87 |
|
|
rdobuilder |
455d87 |
+_pyio_open = getattr(_original_pyio.open, '__wrapped__', _original_pyio.open)
|
|
rdobuilder |
455d87 |
_open = FunctionType(
|
|
|
f9c8e3 |
- six.get_function_code(_original_pyio.open),
|
|
rdobuilder |
455d87 |
+ six.get_function_code(_pyio_open),
|
|
rdobuilder |
455d87 |
_open_environment,
|
|
|
f9c8e3 |
)
|
|
|
f9c8e3 |
|
|
|
f9c8e3 |
|
|
rdobuilder |
455d87 |
From 5641a81d5f7d588c2d452c36479391c71b012e8a Mon Sep 17 00:00:00 2001
|
|
|
f9c8e3 |
From: Tim Burke <tim.burke@gmail.com>
|
|
|
f9c8e3 |
Date: Fri, 11 Jun 2021 13:02:52 -0700
|
|
rdobuilder |
455d87 |
Subject: [PATCH 3/5] Test using eventlet.is_timeout
|
|
|
f9c8e3 |
|
|
|
f9c8e3 |
...rather than requiring an is_timeout attribute on errors.
|
|
|
f9c8e3 |
|
|
|
f9c8e3 |
TimeoutErrors (which are covered by is_timeout) can't necessarily have
|
|
|
f9c8e3 |
attributes added to them.
|
|
|
f9c8e3 |
---
|
|
|
f9c8e3 |
tests/__init__.py | 2 +-
|
|
|
f9c8e3 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
f9c8e3 |
|
|
|
f9c8e3 |
diff --git a/tests/__init__.py b/tests/__init__.py
|
|
|
f9c8e3 |
index c0b64fd9e..188366774 100644
|
|
|
f9c8e3 |
--- a/tests/__init__.py
|
|
|
f9c8e3 |
+++ b/tests/__init__.py
|
|
|
f9c8e3 |
@@ -383,7 +383,7 @@ def run_isolated(path, prefix='tests/isolated/', **kwargs):
|
|
|
f9c8e3 |
|
|
|
f9c8e3 |
def check_is_timeout(obj):
|
|
|
f9c8e3 |
value_text = getattr(obj, 'is_timeout', '(missing)')
|
|
|
f9c8e3 |
- assert obj.is_timeout, 'type={0} str={1} .is_timeout={2}'.format(type(obj), str(obj), value_text)
|
|
|
f9c8e3 |
+ assert eventlet.is_timeout(obj), 'type={0} str={1} .is_timeout={2}'.format(type(obj), str(obj), value_text)
|
|
|
f9c8e3 |
|
|
|
f9c8e3 |
|
|
|
f9c8e3 |
@contextlib.contextmanager
|
|
|
f9c8e3 |
|
|
rdobuilder |
455d87 |
From 2ea6991d26eef98300d27c3c5d383eccc65360c3 Mon Sep 17 00:00:00 2001
|
|
|
f9c8e3 |
From: Tim Burke <tim.burke@gmail.com>
|
|
|
f9c8e3 |
Date: Fri, 11 Jun 2021 13:07:09 -0700
|
|
rdobuilder |
455d87 |
Subject: [PATCH 4/5] Fix backdoor tests on py310
|
|
|
f9c8e3 |
|
|
|
f9c8e3 |
Python 3.10 started including build info on the version line, so the
|
|
|
f9c8e3 |
expectation in tests had to change. Also, start printing the banner as
|
|
|
f9c8e3 |
we read it to aid in future debugging.
|
|
|
f9c8e3 |
---
|
|
rdobuilder |
455d87 |
tests/backdoor_test.py | 5 ++++-
|
|
rdobuilder |
455d87 |
1 file changed, 4 insertions(+), 1 deletion(-)
|
|
|
f9c8e3 |
|
|
|
f9c8e3 |
diff --git a/tests/backdoor_test.py b/tests/backdoor_test.py
|
|
rdobuilder |
455d87 |
index 03a569259..1e09f09b6 100644
|
|
|
f9c8e3 |
--- a/tests/backdoor_test.py
|
|
|
f9c8e3 |
+++ b/tests/backdoor_test.py
|
|
|
f9c8e3 |
@@ -1,5 +1,6 @@
|
|
|
f9c8e3 |
import os
|
|
|
f9c8e3 |
import os.path
|
|
|
f9c8e3 |
+import sys
|
|
|
f9c8e3 |
|
|
|
f9c8e3 |
import eventlet
|
|
|
f9c8e3 |
|
|
rdobuilder |
455d87 |
@@ -22,7 +23,9 @@ def test_server(self):
|
|
|
f9c8e3 |
def _run_test_on_client_and_server(self, client, server_thread):
|
|
|
f9c8e3 |
f = client.makefile('rw')
|
|
rdobuilder |
455d87 |
assert 'Python' in f.readline()
|
|
|
f9c8e3 |
- f.readline() # build info
|
|
|
f9c8e3 |
+ if sys.version_info < (3, 10):
|
|
|
f9c8e3 |
+ # Starting in py310, build info is included in version line
|
|
rdobuilder |
455d87 |
+ f.readline() # build info
|
|
rdobuilder |
455d87 |
f.readline() # help info
|
|
rdobuilder |
455d87 |
assert 'InteractiveConsole' in f.readline()
|
|
|
f9c8e3 |
self.assertEqual('>>> ', f.read(4))
|
|
|
f9c8e3 |
|
|
rdobuilder |
455d87 |
From bad82b6d5634d8cdfa77a2f828abdf61e859a3f4 Mon Sep 17 00:00:00 2001
|
|
|
f9c8e3 |
From: Tim Burke <tim.burke@gmail.com>
|
|
|
f9c8e3 |
Date: Fri, 11 Jun 2021 13:12:36 -0700
|
|
rdobuilder |
455d87 |
Subject: [PATCH 5/5] Tolerate __builtins__ being a dict (rather than module)
|
|
|
f9c8e3 |
in is_timeout
|
|
|
f9c8e3 |
|
|
|
f9c8e3 |
I'm still not sure how this happens, but somehow it does in
|
|
|
f9c8e3 |
socket_test.test_error_is_timeout. As a result, is_timeout wouldn't get
|
|
|
f9c8e3 |
a reference to TimeoutError, so the socket error would not be correctly
|
|
|
f9c8e3 |
identified as a timeout.
|
|
|
f9c8e3 |
---
|
|
rdobuilder |
455d87 |
eventlet/timeout.py | 9 +++++++--
|
|
rdobuilder |
455d87 |
1 file changed, 7 insertions(+), 2 deletions(-)
|
|
|
f9c8e3 |
|
|
|
f9c8e3 |
diff --git a/eventlet/timeout.py b/eventlet/timeout.py
|
|
rdobuilder |
455d87 |
index 6e1e08f63..4ab893eef 100644
|
|
|
f9c8e3 |
--- a/eventlet/timeout.py
|
|
|
f9c8e3 |
+++ b/eventlet/timeout.py
|
|
rdobuilder |
455d87 |
@@ -174,6 +174,11 @@ def fun(*args, **kwargs):
|
|
rdobuilder |
455d87 |
return fun
|
|
|
f9c8e3 |
|
|
|
f9c8e3 |
|
|
rdobuilder |
455d87 |
+if isinstance(__builtins__, dict): # seen when running tests on py310, but HOW??
|
|
rdobuilder |
455d87 |
+ _timeout_err = __builtins__.get('TimeoutError', Timeout)
|
|
rdobuilder |
455d87 |
+else:
|
|
rdobuilder |
455d87 |
+ _timeout_err = getattr(__builtins__, 'TimeoutError', Timeout)
|
|
rdobuilder |
455d87 |
+
|
|
rdobuilder |
455d87 |
+
|
|
|
f9c8e3 |
def is_timeout(obj):
|
|
|
f9c8e3 |
- py3err = getattr(__builtins__, 'TimeoutError', Timeout)
|
|
rdobuilder |
455d87 |
- return bool(getattr(obj, 'is_timeout', False)) or isinstance(obj, py3err)
|
|
rdobuilder |
455d87 |
+ return bool(getattr(obj, 'is_timeout', False)) or isinstance(obj, _timeout_err)
|