Accessbot fix for running on Python 3.12

Since ssl.wrap_context has been removed in Python 3.12,
switch that out with SSLContext.wrap_context instead.

Change-Id: Ic3d7250937544e3a1eda3276db8ed43972735b98
Co-Authored-By: Clark Boylan <clark.boylan@gmail.com>
Depends-On: https://review.opendev.org/945662
This commit is contained in:
Jeremy Stanley 2025-03-26 21:35:46 +00:00
parent 759ab51b32
commit 2fd9d888f9

View File

@ -17,6 +17,7 @@
import configparser
import argparse
import functools
import irc.client
import logging
import ssl
@ -47,7 +48,12 @@ class SetAccess(irc.client.SimpleIRCClient):
self.changes = []
self.identified = False
if self.port == 6697:
factory = irc.connection.Factory(wrapper=ssl.wrap_socket)
# Taken from the example in the Factory class docstring at
# https://github.com/jaraco/irc/blob/main/irc/connection.py
context = ssl.create_default_context()
wrapper = functools.partial(
context.wrap_socket, server_hostname=self.server)
factory = irc.connection.Factory(wrapper=wrapper)
self.connect(self.server, self.port, self.nick,
connect_factory=factory)
else: