public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Lumir Balhar <lbalhar@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/python-idna] rawhide: Fix compatibility with Python 3.16 (rhbz#2576582)
Date: Tue, 24 Nov 2026 11:21:46 GMT	[thread overview]
Message-ID: <179551930661.1.17364436918705992508.rpms-python-idna-b315c44d1f20@fedoraproject.org> (raw)

A new commit has been pushed.

Repo   : rpms/python-idna
Branch : rawhide
Commit : b315c44d1f20277e98c07e2668e1814e749fb561
Author : Lumir Balhar <lbalhar@redhat.com>
Date   : 2026-11-24T12:06:36+01:00
Stats  : +64/-0 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/python-idna/c/b315c44d1f20277e98c07e2668e1814e749fb561?branch=rawhide

Log:
Fix compatibility with Python 3.16 (rhbz#2576582)

---
diff --git a/288.patch b/288.patch
new file mode 100644
index 0000000..2cb201b
--- /dev/null
+++ b/288.patch
@@ -0,0 +1,56 @@
+From 14a9259b9239297d2293e5495ac50c71421cb783 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Lum=C3=ADr=20Balhar?= <frenzy.madness@gmail.com>
+Date: Mon, 23 Nov 2026 11:20:36 +0000
+Subject: [PATCH] Classify empty-basic-section A-labels as non-canonical
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+An A-label whose Punycode payload is a lone leading delimiter, such as
+`xn---bbk` (payload `-bbk`), has no basic code points before the
+delimiter. The Punycode encoder never emits a delimiter in that case, so
+these are always non-canonical "fake A-labels" (RFC 5890 §2.3.2.1).
+
+Until now `ulabel()` relied on the Punycode decoder accepting such input
+and then rejected it via the re-encoding check, raising
+`non_canonical_alabel`. CPython 3.16 makes the decoder reject a leading
+delimiter outright (https://github.com/python/cpython/issues/161090), so
+the decode raises `UnicodeError` first and the label was misclassified as
+`invalid_alabel` instead.
+
+Detect this case explicitly before decoding (last hyphen at index 0) and
+raise `non_canonical_alabel` directly, so the classification is identical
+on all Python versions. Valid labels whose basic section merely starts
+with a hyphen (e.g. `xn----4-p16k` -> `齙--4`) are unaffected, as their
+delimiter is not at index 0.
+
+Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
+---
+ idna/core.py | 14 ++++++++++++++
+ 1 file changed, 14 insertions(+)
+
+diff --git a/idna/core.py b/idna/core.py
+index 6d5a25f..dd61bf6 100644
+--- a/idna/core.py
++++ b/idna/core.py
+@@ -591,6 +591,20 @@ def ulabel(label: str | bytes | bytearray) -> str:
+             raise IDNAError("Malformed A-label, no Punycode eligible content found", code="invalid_alabel")
+         if label_bytes.endswith(b"-"):
+             raise IDNAError("A-label must not end with a hyphen", code="invalid_alabel")
++        if label_bytes.rfind(b"-") == 0:
++            # The Punycode delimiter (the last hyphen) sits at the start, so the
++            # basic code point section is empty. The encoder never emits a
++            # delimiter in that case, so such a label (e.g. ``xn---bbk``) is
++            # always a non-canonical "fake A-label" (RFC 5890 §2.3.2.1). On
++            # Python < 3.16 it would Punycode-decode and be rejected by the
++            # re-encoding check below; Python 3.16 makes the decoder reject a
++            # leading delimiter outright
++            # (https://github.com/python/cpython/issues/161090), which would
++            # otherwise misclassify it as an invalid rather than non-canonical
++            # A-label. Classify it consistently across versions here.
++            raise IDNAError(
++                "A-label is not the canonical Punycode encoding of its U-label", code="non_canonical_alabel"
++            )
+     else:
+         check_label(label_bytes)
+         return label_bytes.decode("ascii")

diff --git a/python-idna.spec b/python-idna.spec
index 9ab206a..c7c78e2 100644
--- a/python-idna.spec
+++ b/python-idna.spec
@@ -11,6 +11,14 @@ Summary:        Internationalized Domain Names in Applications (IDNA)
 License:        BSD-3-Clause
 URL:            https://github.com/kjd/idna
 Source:         https://pypi.io/packages/source/i/%{srcname}/%{srcname}-%{version}.tar.gz
+
+# Classify a non-canonical "fake" A-label such as xn---bbk as non_canonical_alabel
+# rather than invalid_alabel. Python 3.16 made the punycode decoder reject a
+# leading delimiter outright (https://github.com/python/cpython/issues/161090),
+# which changed the error code and broke the test suite (rhbz#2576582).
+# Proposed upstream.
+Patch:          https://github.com/kjd/idna/pull/288.patch
+
 BuildArch:      noarch
 
 BuildRequires:  python3-devel

                 reply	other threads:[~2026-11-24 11:21 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=179551930661.1.17364436918705992508.rpms-python-idna-b315c44d1f20@fedoraproject.org \
    --to=lbalhar@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