python 3.12 import failures

Bug #2044857 reported by Mauricio Faria de Oliveira
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-eventlet (Ubuntu)
Fix Released
Medium
Mauricio Faria de Oliveira

Bug Description

python3-eventlet fails to be imported on python 3.12 (noble-proposed).

$ sudo apt install -y python3-eventlet

$ python3.12 -c 'import eventlet'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/eventlet/__init__.py", line 17, in <module>
    from eventlet import convenience
  File "/usr/lib/python3/dist-packages/eventlet/convenience.py", line 7, in <module>
    from eventlet.green import socket
  File "/usr/lib/python3/dist-packages/eventlet/green/socket.py", line 21, in <module>
    from eventlet.support import greendns
  File "/usr/lib/python3/dist-packages/eventlet/support/greendns.py", line 45, in <module>
    from eventlet.green import ssl
  File "/usr/lib/python3/dist-packages/eventlet/green/ssl.py", line 25, in <module>
    _original_wrap_socket = __ssl.wrap_socket
                            ^^^^^^^^^^^^^^^^^
AttributeError: module 'ssl' has no attribute 'wrap_socket'

There is PR#817 [1] with patches for python 3.12 support,
which is unmerged, but seems to be the only option now,
and is passing the package build-time test-suite.

[1] https://github.com/eventlet/eventlet/pull/817

Tags: patch
Changed in python-eventlet (Ubuntu):
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → Mauricio Faria de Oliveira (mfo)
description: updated
Revision history for this message
Mauricio Faria de Oliveira (mfo) wrote :

Attaching debdiff with PR#817 plus a quick workaround for 2 tests.
The build-time test suite finishes successfully for python 3.12 and 3.11

$ sudo apt install ./python3-eventlet_0.33.1-4ubuntu2_all.deb

$ python3.12 -c 'import eventlet'
$

Changed in python-eventlet (Ubuntu):
status: Confirmed → In Progress
tags: added: patch
Revision history for this message
Mauricio Faria de Oliveira (mfo) wrote :

Checking the autopkgtests for reverse dependencies of python-eventlet,
with python 3.11 (ie, check for no regressions on what currently works)
then python 3.12 (ie, check for no issues on what should work now)

...

Total of 45 source packages for reverse dependencies.
Links for autopkgtests obtained with:

 $ apt rdepends python3-eventlet 2>/dev/null \
   | awk '/Depends: / { print $2 }' \
   | while read pkg; do apt-cache show $pkg \
     | awk '/^Package:/ { pkg=$2 } /^Source:/ { src=$2 } END { if (src) { print src } else { print pkg } }' \
     | while read srcpkg; do \
       echo "https://autopkgtest.ubuntu.com/request.cgi?release=noble&arch=amd64&ppa=mfo/lp2044857&trigger=python-eventlet/0.33.1-4ubuntu2&package=$srcpkg"; \
     done; \
   done

 Example:
 https://autopkgtest.ubuntu.com/request.cgi?release=noble&arch=amd64&ppa=mfo/lp2044857&trigger=python-eventlet/0.33.1-4ubuntu2&package=cinder

...

This only tests python3.11, since it doesn't include the `python3-defaults` change to add python3.12 as supported, currently in noble-proposed [1].

[1] https://launchpad.net/ubuntu/+source/python3-defaults/3.11.4-5ubuntu1

In order to test python3.12 too, such change has to be added to the triggers (and provided in the PPA).

 Example:
 https://autopkgtest.ubuntu.com/request.cgi?release=noble&arch=amd64&ppa=mfo/lp2044857&trigger=python-eventlet/0.33.1-4ubuntu2&trigger=python3-defaults/3.11.4-5ubuntu1&package=cinder

This is more visible in the `autodep8-python3` tests,
that previously only had `Testing with python3.11:`
and now also have `Testing with python3.12`; e.g.:

 1040s autopkgtest [22:31:30]: test autodep8-python3: [-----------------------
 1040s Testing with python3.12:
 1040s <module 'cinder' from '/usr/lib/python3/dist-packages/cinder/__init__.py'>
 1040s Testing with python3.11:
 1040s <module 'cinder' from '/usr/lib/python3/dist-packages/cinder/__init__.py'>
 1041s autopkgtest [22:31:31]: test autodep8-python3: -----------------------]

Revision history for this message
Mauricio Faria de Oliveira (mfo) wrote :

Results:

Python 3.11 continues to work correctly; no regressions.

Python 3.12 regressions: only 1 out of 45 packages
- cinder: autodep-python3 improved (now passing), but cinder-daemons regressed (systemctl restart failed; looking/instrumenting).

Links to the test logs and notes are attached (autopkgtests-logs-notes-py311 and -py312).

Revision history for this message
Mauricio Faria de Oliveira (mfo) wrote :
Revision history for this message
Mauricio Faria de Oliveira (mfo) wrote :
Revision history for this message
Mauricio Faria de Oliveira (mfo) wrote :

Hi Corey,

Here's an updated debdiff that replaces my 'patch 7 import fixup' with an identical change from upstream (which didn't make it to Debian yet, as it's introduced upstream after v0.33.3).

I verified the only changes between debdiffs are a changelog entry and patch metadata (their modified lines are identical).

Thanks,
Mauricio

$ diff -U0 lp2044857_python-eventlet_py312.debdiff lp2044857_python-eventlet_py312-v2.debdiff
...
++ - d/p/py312-import-ssl-from-eventlet-green.patch: update import
++ for patch 7 (due to `eventlet.green.ssl._has_ssl_wrap_socket`)
...
---- python-eventlet-0.33.1/debian/patches/py312-eventlet-pr-817-7-fixup.patch
-+++ python-eventlet-0.33.1/debian/patches/py312-eventlet-pr-817-7-fixup.patch
...
-+- import ssl
-++ from eventlet.green import ssl
...
+--- python-eventlet-0.33.1/debian/patches/py312-import-ssl-from-eventlet-green.patch
++++ python-eventlet-0.33.1/debian/patches/py312-import-ssl-from-eventlet-green.patch
...
++- import ssl
+++ from eventlet.green import ssl
...
@@ -1033 +1042,0 @@
-+py312-eventlet-pr-817-7-fixup.patch
@@ -1035,0 +1045 @@
++py312-import-ssl-from-eventlet-green.patch

Revision history for this message
Corey Bryant (corey.bryant) wrote :

Uploaded, thanks!

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python-eventlet - 0.33.1-4ubuntu2

---------------
python-eventlet (0.33.1-4ubuntu2) noble; urgency=medium

  * Fixes for Python 3.12: (LP: #2044857)
    - d/p/py312-eventlet-pr-817-*.patch: PR#817 (unmerged right now)
    - d/p/py312-import-ssl-from-eventlet-green.patch: update import
      for patch 7 (due to `eventlet.green.ssl._has_ssl_wrap_socket`)
    - d/rules: ignore SyntaxWarnings from nose.config with temporary
      hack until nose has Python 3.12 support in place, for 2 tests:
      - tests.patcher_test.test_builtin and
      - tests.patcher_test.test_import_patched_handles_sub_modules

 -- Mauricio Faria de Oliveira <email address hidden> Mon, 27 Nov 2023 19:01:50 -0300

Changed in python-eventlet (Ubuntu):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.