Skip to content

Commit

Permalink
Add back 3.7 support (#848)
Browse files Browse the repository at this point in the history
* Restore 3.7 support

* Match documented behavior in stdlib

* Pass tests on Python 3.7

---------

Co-authored-by: Itamar Turner-Trauring <itamar@pythonspeed.com>
  • Loading branch information
itamarst and pythonspeed committed Dec 19, 2023
1 parent ac50404 commit 6441021
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
fail-fast: false
matrix:
include:
- { py: 3.7, toxenv: py37-epolls, ignore-error: false, os: ubuntu-latest }
- { py: 3.8, toxenv: py38-epolls, ignore-error: false, os: ubuntu-latest }
- { py: 3.8, toxenv: py38-openssl, ignore-error: false, os: ubuntu-latest }
- { py: 3.8, toxenv: py38-poll, ignore-error: false, os: ubuntu-latest }
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Apologies for any inconvenience.
Supported Python versions
=========================

Python 3.8-3.12 are currently supported.
Python 3.7-3.12 are currently supported.

Flair
=====
Expand Down
15 changes: 12 additions & 3 deletions eventlet/green/ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
_original_sslsocket = __ssl.SSLSocket
_original_sslcontext = __ssl.SSLContext
_is_under_py_3_7 = sys.version_info < (3, 7)
_is_py_3_7 = sys.version_info[:2] == (3, 7)
_original_wrap_socket = __ssl.SSLContext.wrap_socket


Expand Down Expand Up @@ -191,6 +192,11 @@ def _call_trampolining(self, func, *a, **kw):
write=True,
timeout=self.gettimeout(),
timeout_exc=timeout_exc('timed out'))
elif _is_py_3_7 and "unexpected eof" in exc.args[1]:
# For reasons I don't understand on 3.7 we get [ssl:
# KRB5_S_TKT_NYV] unexpected eof while reading]
# errors...
raise IOClosed
else:
raise

Expand All @@ -200,14 +206,17 @@ def write(self, data):
return self._call_trampolining(
super(GreenSSLSocket, self).write, data)

def read(self, *args, **kwargs):
def read(self, len=1024, buffer=None):
"""Read up to LEN bytes and return them.
Return zero-length string on EOF."""
try:
return self._call_trampolining(
super(GreenSSLSocket, self).read, *args, **kwargs)
super(GreenSSLSocket, self).read, len, buffer)
except IOClosed:
return b''
if buffer is None:
return b''
else:
return 0

def send(self, data, flags=0):
if self._sslobj:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ authors = [
]
description = "Highly concurrent networking library"
readme = "README.rst"
requires-python = ">=3.8"
requires-python = ">=3.7"
license = {text = "MIT"}
classifiers = [
"Development Status :: 4 - Beta",
Expand Down
6 changes: 6 additions & 0 deletions tests/wsgi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,12 @@ def server(sock, site, log):
except (ssl.SSLZeroReturnError, ssl.SSLEOFError):
# Can't write a response to a closed TLS session
return True
except OSError:
if sys.version_info[:2] == (3, 7):
return True
else:
traceback.print_exc()
return False
except Exception:
traceback.print_exc()
return False
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ setenv =
{[testenv]setenv}
eventlet_test_ipv6 = 1
deps =
coverage==7.3.3
coverage
pytest
pytest-cov
usedevelop = True
Expand Down Expand Up @@ -60,7 +60,7 @@ setenv =
epolls: EVENTLET_HUB = epolls
tox_cover_args = --cov=eventlet
deps =
coverage==7.3.3
coverage
pytest
pytest-cov
py38-openssl: pyopenssl==22.1.0
Expand Down

0 comments on commit 6441021

Please sign in to comment.