Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.12 fixes by hroncok #817

Merged
merged 17 commits into from
Dec 15, 2023
Merged

Python 3.12 fixes by hroncok #817

merged 17 commits into from
Dec 15, 2023

Conversation

nat-goodspeed
Copy link
Contributor

@nat-goodspeed nat-goodspeed commented Oct 31, 2023

Credit to @hroncok and @vstinner for logic (#797).
This PR attempts to add compatibility for older Python versions.

We draw the line at Python versions that predate ssl.SSLContext, though. The
remaining Python 2.7 documentation doesn't even mention the version at which
that was introduced.

hroncok and others added 5 commits May 17, 2023 13:19
Related to python/cpython@f0b234e

Co-Authored-By: Victor Stinner <vstinner@python.org>
Credit to @hroncok and Victor Stinner <vstinner@python.org> for logic (eventlet#797).
This PR attempts to add compatibility for older Python versions.

We draw the line at Python versions that predate ssl.SSLContext, though. The
remaining Python 2.7 documentation doesn't even mention the version at which
that was introduced.
eventlet/green/ssl.py Outdated Show resolved Hide resolved
tests/tpool_test.py Outdated Show resolved Hide resolved
tests/tpool_test.py Outdated Show resolved Hide resolved
tests/tpool_test.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Nov 1, 2023

Codecov Report

Attention: 14 lines in your changes are missing coverage. Please review.

Comparison is base (d78f8f6) 53% compared to head (4779936) 53%.

Files Patch % Lines
eventlet/green/ssl.py 82% 3 Missing and 5 partials ⚠️
eventlet/green/http/client.py 50% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##           master   #817   +/-   ##
=====================================
  Coverage      53%    53%           
=====================================
  Files          88     88           
  Lines        9848   9865   +17     
  Branches     1841   1846    +5     
=====================================
+ Hits         5299   5323   +24     
+ Misses       4164   4156    -8     
- Partials      385    386    +1     
Flag Coverage Δ
ipv6 22% <40%> (-1%) ⬇️
py310epolls 52% <66%> (+<1%) ⬆️
py310poll 52% <66%> (+<1%) ⬆️
py310selects 52% <66%> (+<1%) ⬆️
py311epolls 52% <66%> (+<1%) ⬆️
py312epolls 50% <74%> (?)
py38epolls 52% <66%> (+<1%) ⬆️
py38openssl 50% <66%> (+<1%) ⬆️
py38poll 52% <66%> (+<1%) ⬆️
py38selects 52% <66%> (+<1%) ⬆️
py39dnspython1 50% <66%> (+<1%) ⬆️
py39epolls 52% <66%> (+<1%) ⬆️
py39poll 52% <66%> (+<1%) ⬆️
py39selects 52% <66%> (+<1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@vstinner
Copy link
Contributor

vstinner commented Nov 1, 2023

FYI Fedora currently uses this patch for Python 3.12: https://src.fedoraproject.org/rpms/python-eventlet/blob/rawhide/f/python3.12.patch

@temoto
Copy link
Member

temoto commented Nov 1, 2023

@vstinner thanks, i hope few small changes here would not create conflict issue in fedora?

@vstinner
Copy link
Contributor

vstinner commented Nov 1, 2023

@vstinner thanks, i hope few small changes here would not create conflict issue in fedora?

If eventlet is ported to Python 3.12, we will just remove our patch in Fedora and update the package to the new eventlet release.

@nat-goodspeed
Copy link
Contributor Author

I'm sorry to say I don't know how to resolve the many failures of verify_hub_empty() or

ssl.SSLError: [SSL: KRB5_S_TKT_NYV] unexpected eof while reading (_ssl.c:2570)

I'm willing to work on a fix if I could have diagnostic help.

@nat-goodspeed nat-goodspeed marked this pull request as draft November 1, 2023 00:47
@temoto
Copy link
Member

temoto commented Nov 1, 2023

I'm sorry to say I don't know how to resolve the many failures of verify_hub_empty() or

ssl.SSLError: [SSL: KRB5_S_TKT_NYV] unexpected eof while reading (_ssl.c:2570)

I'm willing to work on a fix if I could have diagnostic help.

95% sure that is not related to this changeset.

KRB5_S_TKT_NYV seems like openssl compatibility, non empty hub is likely ref count (mem leak).

@nat-goodspeed
Copy link
Contributor Author

Have you seen similar failures on other branches?

@temoto
Copy link
Member

temoto commented Nov 1, 2023

Have you seen similar failures on other branches?

verify_hub_empty occurred on nose branch. KRB5_S_TKT_NYV is new.

@nat-goodspeed
Copy link
Contributor Author

I ran the tests locally on Python 3.10 against master and against this python3.12 branch, and there was only one difference (other than timestamps, object IDs and PIDs).

======================================================================
FAIL: test_024_expect_100_continue (tests.wsgi_test.TestHttpd)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/nat/linden/eventlet-nat/tests/wsgi_test.py", line 825, in test_024_expect_100_continue
    with self.assertRaises(socket.error) as caught:
AssertionError: OSError not raised

======================================================================

Really, the question is: if this unblocks Python 3.12, is it worth merging?

@jayofdoom
Copy link
Contributor

Thanks for working on this.

A major downside to the approach taken here is the inability for library callers to configure the SSLContext. I wonder if there's a way to factor this where the application using the eventlet ssl module can offer some configuration -- or maybe even a preconfigured SSLContext -- in order to allow the application control over what TLS/SSL versions are supported, and certificates accepted.

@jayofdoom
Copy link
Contributor

I know @itamarst was going to take a look at py 3.12 support in eventlet as well. I've linked this PR to him.

@itamarst
Copy link
Contributor

itamarst commented Nov 1, 2023

I'm happy to leave this part to someone else, but I've been just trying to get tests to run on 3.12 and discovered nose3 is not compatible with 3.12. So I'm going to see if I can fix that (see #638 for previous discussion of nose).

@nat-goodspeed
Copy link
Contributor Author

@jayofdoom

A major downside to the approach taken here is the inability for library callers to configure the SSLContext.

It looks as though you can instantiate GreenSSLSocket(..., _context=my_context). Maybe that should be more prominently exposed? I'm open to suggestion on this point.

@itamarst
Copy link
Contributor

#823 has a bunch of fixes to make tests pass, so should be helpful in validating 3.12 support actually works.

@doko42
Copy link

doko42 commented Dec 7, 2023

python 3.12 support needs an update for the cpython 3.12 branch apparently, see
python/cpython#112826

@onlined
Copy link

onlined commented Dec 9, 2023

Quoting from Python documentation:

Deprecated since version 3.7: Since Python 3.2 and 2.7.9, it is recommended to use the SSLContext.wrap_socket() instead of wrap_socket(). The top-level function is limited and creates an insecure client socket without server name indication or hostname matching.

I think it's not needed anymore to use ssl.wrap_socket and do unnecessary branching because eventlet doesn't support versions older than 3.2 and 2.7. You can only use SSLContext.wrap_socket. Am I missing something?

@4383
Copy link
Member

4383 commented Dec 14, 2023

Now that many CI fixes have been merged (thanks @itamarst), I think we can rerun checks. Normally, Py38 to Py311 jobs should be green.

@itamarst
Copy link
Contributor

I got everything passing. Further steps... since we're supporting 3.8+, and 3.8 already has ssl.SSLContext, possibly the ssl.wrap_socket codepath can just be dropped altogether.

@itamarst itamarst marked this pull request as ready for review December 15, 2023 16:21
@itamarst
Copy link
Contributor

Note there were some random irrelevant changes to test modules in the original PR.

@itamarst itamarst mentioned this pull request Dec 15, 2023
@@ -1450,35 +1450,21 @@ def getresponse(self):
except ImportError:
pass
else:
if ssl._has_ssl_wrap_socket:
Copy link
Member

@4383 4383 Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm... I'm not sure to understand your intentions here.
Your commit message said that we only support py38 ("Simplify given we only support 3.8+") but you removed the section related to py311 and earlier versions and you keep the code related to py312.

Should we not keep this condition to differentiate Py38-Py311 and Py312+.

Please can you give more details about your thinking.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original comment was wrong. It assumed the new API is new in 3.12, but it actually exists in 3.8 too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack. thanks for details. Then LGTM

Copy link
Member

@4383 4383 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

As this a significant step for eventlet I'd suggest release a new version now, when this patch will be merged.

@itamarst: Is it ok for you? If yes, do you want to proceed the new tag and the build/upload?

@4383 4383 merged commit e51f72a into eventlet:master Dec 15, 2023
18 checks passed
@4383 4383 mentioned this pull request Dec 15, 2023
openstack-mirroring pushed a commit to openstack/requirements that referenced this pull request Jan 16, 2024
Several important and urgent fixes are released there.

0.34.3
======

eventlet/eventlet#875

* Fix security issue in the wsgi module related to RFC 9112 eventlet/eventlet#826
* Fix segfault, a new approach for greening existing locks eventlet/eventlet#866
* greendns: fix getaddrinfo parameter name eventlet/eventlet#809
* Fix deprecation warning on ssl.PROTOCOL_TLS eventlet/eventlet#872
* Pytests, fix error at teardown of TestGreenSocket.test_full_duplex eventlet/eventlet#871
* Skip test which uses Py cgi module eventlet/eventlet#865
* Drop old code based on python < 3.7.34.2
======

eventlet/eventlet#861

* Allowing inheritance of GreenSSLSocket without overriding the __new_ method eventlet/eventlet#796
* [bug] Fix broken API related to `__version__` removal eventlet/eventlet#859
* [doc] Fix pypi broken link eventlet/eventlet#857

0.34.1
======

eventlet/eventlet#842

* [bug] Fix memory leak in greendns eventlet/eventlet#810
* [infra] Fix OIDC authentication failure eventlet/eventlet#855
* [bug] Ignore asyncore and asynchat for Python 3.12+ eventlet/eventlet#804

0.34.0 (Not released on Pypi but landed with 0.34.1)
====================================================

* Dropped support for Python 3.6 and earlier.
* Fix Python 3.13 compat by adding missing attibute '_is_main_interpreter' eventlet/eventlet#847
* Add support of Python 3.12 eventlet/eventlet#817
* Drop unmaintained and unused stdlib tests eventlet/eventlet#820
* Fix tests and CI for Python 3.7 and higher eventlet/eventlet#831 and eventlet/eventlet#832
* Stop claiming to create universal wheels eventlet/eventlet#841
* Fix green logging locks for Python versions <= 3.10 eventlet/eventlet#754

Change-Id: Ib2e59a207b86ae90fa391bf1dff7819851dc9c9b
openstack-mirroring pushed a commit to openstack/openstack that referenced this pull request Jan 16, 2024
* Update requirements from branch 'master'
  to 827a86739e66ffb537b5ea7a65a3cc74eb3fabf1
  - Merge "Update eventlet to 0.34.3"
  - Update eventlet to 0.34.3
    
    Several important and urgent fixes are released there.
    
    0.34.3
    ======
    
    eventlet/eventlet#875
    
    * Fix security issue in the wsgi module related to RFC 9112 eventlet/eventlet#826
    * Fix segfault, a new approach for greening existing locks eventlet/eventlet#866
    * greendns: fix getaddrinfo parameter name eventlet/eventlet#809
    * Fix deprecation warning on ssl.PROTOCOL_TLS eventlet/eventlet#872
    * Pytests, fix error at teardown of TestGreenSocket.test_full_duplex eventlet/eventlet#871
    * Skip test which uses Py cgi module eventlet/eventlet#865
    * Drop old code based on python < 3.7.34.2
    ======
    
    eventlet/eventlet#861
    
    * Allowing inheritance of GreenSSLSocket without overriding the __new_ method eventlet/eventlet#796
    * [bug] Fix broken API related to `__version__` removal eventlet/eventlet#859
    * [doc] Fix pypi broken link eventlet/eventlet#857
    
    0.34.1
    ======
    
    eventlet/eventlet#842
    
    * [bug] Fix memory leak in greendns eventlet/eventlet#810
    * [infra] Fix OIDC authentication failure eventlet/eventlet#855
    * [bug] Ignore asyncore and asynchat for Python 3.12+ eventlet/eventlet#804
    
    0.34.0 (Not released on Pypi but landed with 0.34.1)
    ====================================================
    
    * Dropped support for Python 3.6 and earlier.
    * Fix Python 3.13 compat by adding missing attibute '_is_main_interpreter' eventlet/eventlet#847
    * Add support of Python 3.12 eventlet/eventlet#817
    * Drop unmaintained and unused stdlib tests eventlet/eventlet#820
    * Fix tests and CI for Python 3.7 and higher eventlet/eventlet#831 and eventlet/eventlet#832
    * Stop claiming to create universal wheels eventlet/eventlet#841
    * Fix green logging locks for Python versions <= 3.10 eventlet/eventlet#754
    
    Change-Id: Ib2e59a207b86ae90fa391bf1dff7819851dc9c9b
openstack-mirroring pushed a commit to openstack/openstack that referenced this pull request Jan 30, 2024
* Update requirements from branch 'master'
  to 08f829d8375b4059af365191e0907069be9fb739
  - Update eventlet to 0.35.0
    
    0.35.0
    ======
    
    eventlet/eventlet#897
    
    * [fix] fix truncate size nullable eventlet/eventlet#789
    * [fix] Handle transport endpoint shutdown in conditions eventlet/eventlet#884
    * [fix] Rework reject_bad_requests option eventlet/eventlet#890
    * [fix] Fix NameError introduced by #826 eventlet/eventlet#890
    * [feature] Support awaiting GreenThread in an `async def` context eventlet/eventlet#889
    * [feature] Asyncio hub support for Python 3.7 to 3.9 eventlet/eventlet#886
    * [fix] Fix bad exceptions handlings eventlet/eventlet#883
    * [feature] Support using asyncio coroutines from inside greenlets eventlet/eventlet#877
    * [removal] Remove deprecated CGIHTTPServer and SimpleHTTPServer eventlet/eventlet#881
    * [feature] Add an asyncio hub for eventlet eventlet/eventlet#870
    
    0.34.3
    ======
    
    eventlet/eventlet#875
    
    * Fix security issue in the wsgi module related to RFC 9112 eventlet/eventlet#826
    * Fix segfault, a new approach for greening existing locks eventlet/eventlet#866
    * greendns: fix getaddrinfo parameter name eventlet/eventlet#809
    * Fix deprecation warning on ssl.PROTOCOL_TLS eventlet/eventlet#872
    * Pytests, fix error at teardown of TestGreenSocket.test_full_duplex eventlet/eventlet#871
    * Skip test which uses Py cgi module eventlet/eventlet#865
    * Drop old code based on python < 3.7.34.2
    ======
    
    eventlet/eventlet#861
    
    * Allowing inheritance of GreenSSLSocket without overriding the __new_ method eventlet/eventlet#796
    * [bug] Fix broken API related to `__version__` removal eventlet/eventlet#859
    * [doc] Fix pypi broken link eventlet/eventlet#857
    
    0.34.1
    ======
    
    eventlet/eventlet#842
    
    * [bug] Fix memory leak in greendns eventlet/eventlet#810
    * [infra] Fix OIDC authentication failure eventlet/eventlet#855
    * [bug] Ignore asyncore and asynchat for Python 3.12+ eventlet/eventlet#804
    
    0.34.0 (Not released on Pypi but landed with 0.34.1)
    ====================================================
    
    * Dropped support for Python 3.6 and earlier.
    * Fix Python 3.13 compat by adding missing attibute '_is_main_interpreter' eventlet/eventlet#847
    * Add support of Python 3.12 eventlet/eventlet#817
    * Drop unmaintained and unused stdlib tests eventlet/eventlet#820
    * Fix tests and CI for Python 3.7 and higher eventlet/eventlet#831 and eventlet/eventlet#832
    * Stop claiming to create universal wheels eventlet/eventlet#841
    * Fix green logging locks for Python versions <= 3.10 eventlet/eventlet#754
    
    Change-Id: I909be1d1812eaed574525866dbc123083684571d
openstack-mirroring pushed a commit to openstack/requirements that referenced this pull request Jan 30, 2024
0.35.0
======

eventlet/eventlet#897

* [fix] fix truncate size nullable eventlet/eventlet#789
* [fix] Handle transport endpoint shutdown in conditions eventlet/eventlet#884
* [fix] Rework reject_bad_requests option eventlet/eventlet#890
* [fix] Fix NameError introduced by #826 eventlet/eventlet#890
* [feature] Support awaiting GreenThread in an `async def` context eventlet/eventlet#889
* [feature] Asyncio hub support for Python 3.7 to 3.9 eventlet/eventlet#886
* [fix] Fix bad exceptions handlings eventlet/eventlet#883
* [feature] Support using asyncio coroutines from inside greenlets eventlet/eventlet#877
* [removal] Remove deprecated CGIHTTPServer and SimpleHTTPServer eventlet/eventlet#881
* [feature] Add an asyncio hub for eventlet eventlet/eventlet#870

0.34.3
======

eventlet/eventlet#875

* Fix security issue in the wsgi module related to RFC 9112 eventlet/eventlet#826
* Fix segfault, a new approach for greening existing locks eventlet/eventlet#866
* greendns: fix getaddrinfo parameter name eventlet/eventlet#809
* Fix deprecation warning on ssl.PROTOCOL_TLS eventlet/eventlet#872
* Pytests, fix error at teardown of TestGreenSocket.test_full_duplex eventlet/eventlet#871
* Skip test which uses Py cgi module eventlet/eventlet#865
* Drop old code based on python < 3.7.34.2
======

eventlet/eventlet#861

* Allowing inheritance of GreenSSLSocket without overriding the __new_ method eventlet/eventlet#796
* [bug] Fix broken API related to `__version__` removal eventlet/eventlet#859
* [doc] Fix pypi broken link eventlet/eventlet#857

0.34.1
======

eventlet/eventlet#842

* [bug] Fix memory leak in greendns eventlet/eventlet#810
* [infra] Fix OIDC authentication failure eventlet/eventlet#855
* [bug] Ignore asyncore and asynchat for Python 3.12+ eventlet/eventlet#804

0.34.0 (Not released on Pypi but landed with 0.34.1)
====================================================

* Dropped support for Python 3.6 and earlier.
* Fix Python 3.13 compat by adding missing attibute '_is_main_interpreter' eventlet/eventlet#847
* Add support of Python 3.12 eventlet/eventlet#817
* Drop unmaintained and unused stdlib tests eventlet/eventlet#820
* Fix tests and CI for Python 3.7 and higher eventlet/eventlet#831 and eventlet/eventlet#832
* Stop claiming to create universal wheels eventlet/eventlet#841
* Fix green logging locks for Python versions <= 3.10 eventlet/eventlet#754

Change-Id: I909be1d1812eaed574525866dbc123083684571d
@nat-goodspeed nat-goodspeed deleted the python3.12 branch April 2, 2024 17:37
tanaypf9 pushed a commit to tanaypf9/pf9-requirements that referenced this pull request May 20, 2024
Several important and urgent fixes are released there.

0.34.1
======

* [bug] Fix memory leak in greendns eventlet/eventlet#810
* [infra] Fix OIDC authentication failure eventlet/eventlet#855
* [bug] Ignore asyncore and asynchat for Python 3.12+ eventlet/eventlet#804

0.34.0 (Not released on Pypi but landed with 0.34.1)
====================================================

* Dropped support for Python 3.6 and earlier.
* Fix Python 3.13 compat by adding missing attibute '_is_main_interpreter' eventlet/eventlet#847
* Add support of Python 3.12 eventlet/eventlet#817
* Drop unmaintained and unused stdlib tests eventlet/eventlet#820
* Fix tests and CI for Python 3.7 and higher eventlet/eventlet#831 and eventlet/eventlet#832
* Stop claiming to create universal wheels eventlet/eventlet#841
* Fix green logging locks for Python versions <= 3.10 eventlet/eventlet#754

Change-Id: Ib2e59a207b86ae90fa391bf1dff7819851dc9c9b
tanaypf9 pushed a commit to tanaypf9/pf9-requirements that referenced this pull request May 20, 2024
Several important and urgent fixes are released there.

0.34.2
======

eventlet/eventlet#861

* Allowing inheritance of GreenSSLSocket without overriding the __new_ method eventlet/eventlet#796
* [bug] Fix broken API related to `__version__` removal eventlet/eventlet#859
* [doc] Fix pypi broken link eventlet/eventlet#857

0.34.1
======

eventlet/eventlet#842

* [bug] Fix memory leak in greendns eventlet/eventlet#810
* [infra] Fix OIDC authentication failure eventlet/eventlet#855
* [bug] Ignore asyncore and asynchat for Python 3.12+ eventlet/eventlet#804

0.34.0 (Not released on Pypi but landed with 0.34.1)
====================================================

* Dropped support for Python 3.6 and earlier.
* Fix Python 3.13 compat by adding missing attibute '_is_main_interpreter' eventlet/eventlet#847
* Add support of Python 3.12 eventlet/eventlet#817
* Drop unmaintained and unused stdlib tests eventlet/eventlet#820
* Fix tests and CI for Python 3.7 and higher eventlet/eventlet#831 and eventlet/eventlet#832
* Stop claiming to create universal wheels eventlet/eventlet#841
* Fix green logging locks for Python versions <= 3.10 eventlet/eventlet#754

Change-Id: Ib2e59a207b86ae90fa391bf1dff7819851dc9c9b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants