module 'ssl' has no attribute 'wrap_socket'

Bug #2065876 reported by Mats Utterheim
32
This bug affects 6 people
Affects Status Importance Assigned to Milestone
mysql-connector-python (Ubuntu)
Confirmed
Undecided
Unassigned
python-pyvmomi (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

pyVmomi is not working with python 3.12 that ships with 24.04.

There is a commit in the official GIT repo to fix this. https://github.com/vmware/pyvmomi/commit/44d7b9f0c201a92018bac8324542c0adf96aa148

Here is an example of the errors you get when using it:
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: module 'ssl' has no attribute 'wrap_socket'
fatal: [svnipap-0009 -> localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):
  File \"/root/.ansible/tmp/ansible-tmp-1715850077.213712-12628-91429943003605/AnsiballZ_vmware_guest_find.py\", line 107, in <module>
    _ansiballz_main()
  File \"/root/.ansible/tmp/ansible-tmp-1715850077.213712-12628-91429943003605/AnsiballZ_vmware_guest_find.py\", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File \"/root/.ansible/tmp/ansible-tmp-1715850077.213712-12628-91429943003605/AnsiballZ_vmware_guest_find.py\", line 47, in invoke_module
    runpy.run_module(mod_name='ansible_collections.community.vmware.plugins.modules.vmware_guest_find', init_globals=dict(_module_fqn='ansible_collections.community.vmware.plugins.modules.vmware_guest_find', _modlib_path=modlib_path),
  File \"<frozen runpy>\", line 226, in run_module
  File \"<frozen runpy>\", line 98, in _run_module_code
  File \"<frozen runpy>\", line 88, in _run_code
  File \"/tmp/ansible_vmware_guest_find_payload_co4dlvzj/ansible_vmware_guest_find_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest_find.py\", line 74, in <module>
  File \"/tmp/ansible_vmware_guest_find_payload_co4dlvzj/ansible_vmware_guest_find_payload.zip/ansible_collections/community/vmware/plugins/module_utils/vmware.py\", line 39, in <module>
  File \"/usr/lib/python3/dist-packages/pyVim/connect.py\", line 37, in <module>
    from pyVmomi import vim, vmodl, SoapStubAdapter, SessionOrientedStub
  File \"/usr/lib/python3/dist-packages/pyVmomi/__init__.py\", line 204, in <module>
    from pyVmomi.SoapAdapter import SoapStubAdapter, StubAdapterBase, SoapCmdStubAdapter, \\
  File \"/usr/lib/python3/dist-packages/pyVmomi/SoapAdapter.py\", line 993, in <module>
    _SocketWrapper = ssl.wrap_socket
                     ^^^^^^^^^^^^^^^
AttributeError: module 'ssl' has no attribute 'wrap_socket'
", "module_stdout": "", "msg": "MODULE FAILURE
See stdout/stderr for the exact error", "rc": 1}

Steps to reproduce:

# python3 -c 'from pyVim import connect'

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/pyVim/connect.py", line 37, in <module>
    from pyVmomi import vim, vmodl, SoapStubAdapter, SessionOrientedStub
  File "/usr/lib/python3/dist-packages/pyVmomi/__init__.py", line 204, in <module>
    from pyVmomi.SoapAdapter import SoapStubAdapter, StubAdapterBase, SoapCmdStubAdapter, \
  File "/usr/lib/python3/dist-packages/pyVmomi/SoapAdapter.py", line 993, in <module>
    _SocketWrapper = ssl.wrap_socket
                     ^^^^^^^^^^^^^^^
AttributeError: module 'ssl' has no attribute 'wrap_socket'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 228, in partial_apport_excepthook
    return apport_excepthook(binary, exc_type, exc_obj, exc_tb)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 114, in apport_excepthook
    report["ExecutableTimestamp"] = str(int(os.stat(binary).st_mtime))
                                            ^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/etc/ansible/playbooks/-c'

Original exception was:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/pyVim/connect.py", line 37, in <module>
    from pyVmomi import vim, vmodl, SoapStubAdapter, SessionOrientedStub
  File "/usr/lib/python3/dist-packages/pyVmomi/__init__.py", line 204, in <module>
    from pyVmomi.SoapAdapter import SoapStubAdapter, StubAdapterBase, SoapCmdStubAdapter, \
  File "/usr/lib/python3/dist-packages/pyVmomi/SoapAdapter.py", line 993, in <module>
    _SocketWrapper = ssl.wrap_socket
                     ^^^^^^^^^^^^^^^
AttributeError: module 'ssl' has no attribute 'wrap_socket'

Revision history for this message
Thomas Dreibholz (dreibh) wrote :

The issue also affects the package python3-mysql.connector:

  File "/usr/lib/python3/dist-packages/mysql/connector/__init__.py", line 173, in connect
    return MySQLConnection(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/mysql/connector/connection.py", line 102, in __init__
    self.connect(**kwargs)
  File "/usr/lib/python3/dist-packages/mysql/connector/abstracts.py", line 735, in connect
    self._open_connection()
  File "/usr/lib/python3/dist-packages/mysql/connector/connection.py", line 250, in _open_connection
    self._do_auth(self._user, self._password,
  File "/usr/lib/python3/dist-packages/mysql/connector/connection.py", line 155, in _do_auth
    self._socket.switch_to_ssl(ssl_options.get('ca'),
  File "/usr/lib/python3/dist-packages/mysql/connector/network.py", line 427, in switch_to_ssl
    self.sock = ssl.wrap_socket(
                ^^^^^^^^^^^^^^^
AttributeError: module 'ssl' has no attribute 'wrap_socket'

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

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in mysql-connector-python (Ubuntu):
status: New → Confirmed
Changed in python-pyvmomi (Ubuntu):
status: New → Confirmed
Revision history for this message
Patrice Belleville (patrice0) wrote :

Version 8.0 of python3-mysql.connector supports python versions 3.11, 3.10, 3.9, 3.8, 3.7, (3.6 before 8.0.29), (2.7 and 3.5 before 8.0.24), but NOT version 3.12 which is what ships with noble.

Revision history for this message
Thomas Dreibholz (dreibh) wrote :

Yes, version 8.0.15 (current version in Ubuntu 24.04) is too old.

The python3-mysql.connector package needs an upgrade to version 8.4, which supports Python 3.12 (-> https://dev.mysql.com/doc/connector-python/en/connector-python-versions.html).

Revision history for this message
Konstantin (hi-angel-y) wrote :

@MatsUtterheim you seem to have forgotten to write steps to reproduce, please add it to the post: to reproduce just execute:

    python3 -c 'from pyVim import connect'

…on ubuntu 24.04

Revision history for this message
Mats Utterheim (mats-utterheim) wrote :

Thank you. Updated the post with steps to reproduce

description: updated
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.