public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Michal Schorm <mschorm@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/mysql-connector-python] f45: [rebase 3/4] Add Python 3.15 SSL compatibility patch
Date: Tue, 22 Sep 2026 12:14:48 GMT	[thread overview]
Message-ID: <179007928830.1.6241616898001853829.rpms-mysql-connector-python-10c87e4fe65e@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/mysql-connector-python
            Branch : f45
            Commit : 10c87e4fe65e53d60997a1b22f7b67fd8e9316b2
            Author : Michal Schorm <mschorm@redhat.com>
            Date   : 2026-09-22T12:15:12+02:00
            Stats  : +76/-0 in 2 file(s)
            URL    : https://src.fedoraproject.org/rpms/mysql-connector-python/c/10c87e4fe65e53d60997a1b22f7b67fd8e9316b2?branch=f45

            Log:
            [rebase 3/4] Add Python 3.15 SSL compatibility patch

Guard 'ssl.PROTOCOL_TLSv1', 'ssl.PROTOCOL_TLSv1_1', and
'ssl.PROTOCOL_TLSv1_2' with hasattr() checks in three files:
'network.py', 'aio/network.py', and 'connection.py'.

Python 3.15 (PEP 644) removed these legacy TLS protocol constants.
Without this patch, any code path touching TLS version selection
raises AttributeError on Python 3.15+.

Co-Authored-By: Claude AI <noreply@anthropic.com>

---
diff --git a/mysql-connector-python-python315-ssl.patch b/mysql-connector-python-python315-ssl.patch
new file mode 100644
index 0000000..57dff85
--- /dev/null
+++ b/mysql-connector-python-python315-ssl.patch
@@ -0,0 +1,74 @@
+# Fix Python 3.15 SSL/TLS compatibility
+#
+# Python 3.15 removed the deprecated ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1_1,
+# and ssl.PROTOCOL_TLSv1_2 constants (PEP 644). The hardcoded dictionary
+# construction raises AttributeError on Python 3.15+.
+#
+# Replace direct references with hasattr() guards so only the constants
+# available on the running Python version are registered. TLS 1.0 and 1.1
+# are obsolete anyway — the main functional protocol is TLSv1.3 via
+# ssl.PROTOCOL_TLS.
+
+--- a/mysql-connector-python/lib/mysql/connector/network.py	2026-07-10 20:39:31.000000000 +0200
++++ b/mysql-connector-python/lib/mysql/connector/network.py	2026-09-22 01:30:35.259915967 +0200
+@@ -42,12 +42,15 @@
+ try:
+     import ssl
+ 
+-    TLS_VERSIONS = {
+-        "TLSv1": ssl.PROTOCOL_TLSv1,
+-        "TLSv1.1": ssl.PROTOCOL_TLSv1_1,
+-        "TLSv1.2": ssl.PROTOCOL_TLSv1_2,
+-        "TLSv1.3": ssl.PROTOCOL_TLS,
+-    }
++    TLS_VERSIONS = {}
++    if hasattr(ssl, "PROTOCOL_TLSv1"):
++        TLS_VERSIONS["TLSv1"] = ssl.PROTOCOL_TLSv1
++    if hasattr(ssl, "PROTOCOL_TLSv1_1"):
++        TLS_VERSIONS["TLSv1.1"] = ssl.PROTOCOL_TLSv1_1
++    if hasattr(ssl, "PROTOCOL_TLSv1_2"):
++        TLS_VERSIONS["TLSv1.2"] = ssl.PROTOCOL_TLSv1_2
++    if hasattr(ssl, "PROTOCOL_TLS"):
++        TLS_VERSIONS["TLSv1.3"] = ssl.PROTOCOL_TLS
+     TLS_V1_3_SUPPORTED = hasattr(ssl, "HAS_TLSv1_3") and ssl.HAS_TLSv1_3
+ except ImportError:
+     # If import fails, we don't have SSL support.
+--- a/mysql-connector-python/lib/mysql/connector/aio/network.py	2026-07-10 20:39:31.000000000 +0200
++++ b/mysql-connector-python/lib/mysql/connector/aio/network.py	2026-09-22 01:30:40.841840964 +0200
+@@ -40,12 +40,15 @@
+ try:
+     import ssl
+ 
+-    TLS_VERSIONS = {
+-        "TLSv1": ssl.PROTOCOL_TLSv1,
+-        "TLSv1.1": ssl.PROTOCOL_TLSv1_1,
+-        "TLSv1.2": ssl.PROTOCOL_TLSv1_2,
+-        "TLSv1.3": ssl.PROTOCOL_TLS,
+-    }
++    TLS_VERSIONS = {}
++    if hasattr(ssl, "PROTOCOL_TLSv1"):
++        TLS_VERSIONS["TLSv1"] = ssl.PROTOCOL_TLSv1
++    if hasattr(ssl, "PROTOCOL_TLSv1_1"):
++        TLS_VERSIONS["TLSv1.1"] = ssl.PROTOCOL_TLSv1_1
++    if hasattr(ssl, "PROTOCOL_TLSv1_2"):
++        TLS_VERSIONS["TLSv1.2"] = ssl.PROTOCOL_TLSv1_2
++    if hasattr(ssl, "PROTOCOL_TLS"):
++        TLS_VERSIONS["TLSv1.3"] = ssl.PROTOCOL_TLS
+ except ImportError:
+     ssl = None
+ 
+--- a/mysqlx-connector-python/lib/mysqlx/connection.py	2026-07-10 20:39:31.000000000 +0200
++++ b/mysqlx-connector-python/lib/mysqlx/connection.py	2026-09-22 01:30:46.047770854 +0200
+@@ -38,9 +38,9 @@
+     import ssl
+ 
+     SSL_AVAILABLE = True
+-    TLS_VERSIONS = {
+-        "TLSv1.2": ssl.PROTOCOL_TLSv1_2,
+-    }
++    TLS_VERSIONS = {}
++    if hasattr(ssl, "PROTOCOL_TLSv1_2"):
++        TLS_VERSIONS["TLSv1.2"] = ssl.PROTOCOL_TLSv1_2
+     # TLSv1.3 included in PROTOCOL_TLS, but PROTOCOL_TLS is not included on 3.4
+     TLS_VERSIONS["TLSv1.3"] = (
+         ssl.PROTOCOL_TLS

diff --git a/mysql-connector-python.spec b/mysql-connector-python.spec
index 6dd5884..1b60a0b 100644
--- a/mysql-connector-python.spec
+++ b/mysql-connector-python.spec
@@ -31,6 +31,8 @@ Source0:        %{name}-%{version}-src-without-fonts.tar.gz
 Patch0:         %{name}-rpath.patch
 # Fix sphinx conf.py version import for the split source layout
 Patch1:         %{name}-docs-import.patch
+# Guard removed ssl.PROTOCOL_TLSv1* constants with hasattr() (Python 3.15, PEP 644)
+Patch2:         %{name}-python315-ssl.patch
 
 BuildRequires:  gcc-c++
 BuildRequires:  make

                 reply	other threads:[~2026-09-22 12:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179007928830.1.6241616898001853829.rpms-mysql-connector-python-10c87e4fe65e@fedoraproject.org \
    --to=mschorm@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox