Bug 2576582

Summary: python-idna fails to build with Python 3.16: test_every_error_code_is_raisable: AssertionError: 'invalid_alabel' != 'non_canonical_alabel'
Product: [Fedora] Fedora Reporter: Karolina Surma <ksurma>
Component: python-idnaAssignee: Lumír Balhar <lbalhar>
Status: NEW --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: cstratak, ksurma, lbalhar, mhroncok, python-packagers-sig
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2567340    

Description Karolina Surma 2026-11-19 12:48:58 UTC
python-idna fails to build with Python 3.16.0a2.

_ ErrorAttributeTests.test_every_error_code_is_raisable (code='non_canonical_alabel') _

self = <tests.test_idna_errors.ErrorAttributeTests testMethod=test_every_error_code_is_raisable>

    def test_every_error_code_is_raisable(self):
        """Each code has an input that produces it, and vice versa."""
        r = "\u05d0"
        an = "\u0660"
        triggers = {
            "input_too_long": lambda: idna.encode("a" * 1025),
            "label_too_long": lambda: idna.alabel("a" * 64),
            "domain_too_long": lambda: idna.encode(".".join(["a" * 63] * 4)),
            "empty_label": lambda: idna.encode("a..b"),
            "empty_domain": lambda: idna.encode(""),
            "not_nfc": lambda: idna.alabel("e\u0301xample"),
            "hyphen_3_4": lambda: idna.alabel("ab--cd"),
            "hyphen_start_end": lambda: idna.alabel("-abc"),
            "leading_combiner": lambda: idna.alabel("\u0301abc"),
            "disallowed_codepoint": lambda: idna.alabel("abc\u0141"),
            "contextj": lambda: idna.alabel("a\u200cb"),
            "contexto": lambda: idna.alabel("a\xb7b"),
            "unknown_codepoint": self._unknown_codepoint,
            "bidi_rule_1": lambda: idna.check_bidi(an + r),
            "bidi_rule_2": lambda: idna.check_bidi(r + "a"),
            "bidi_rule_3": lambda: idna.check_bidi(r + "-"),
            "bidi_rule_4": lambda: idna.check_bidi(r + an + "0"),
            "bidi_rule_5": lambda: idna.alabel("a" + r),
            "bidi_rule_6": lambda: idna.check_bidi("a-", check_ltr=True),
            "bidi_unknown_direction": lambda: self._unknown_direction("ab"),
            "invalid_alabel": lambda: idna.ulabel("xn--"),
            "non_canonical_alabel": lambda: idna.ulabel("xn---bbk"),
            "invalid_ascii": lambda: idna.encode(b"\xff"),
            "invalid_utf8": lambda: idna.check_label(b"\xff"),
            "uts46_disallowed": lambda: idna.uts46_remap("a\x80"),
            "uts46_std3": lambda: idna.uts46_remap("a_b"),
            "unsupported_errors": lambda: codecs.encode("a", "idna2008", errors="ignore"),
        }
        codes = set(get_args(idna.core._ErrorCode))
        self.assertEqual(set(triggers), codes)
        for code, trigger in triggers.items():
            with self.subTest(code=code):
                with self.assertRaises(idna.IDNAError) as ctx:
                    trigger()
>               self.assertEqual(ctx.exception.code, code)
E               AssertionError: 'invalid_alabel' != 'non_canonical_alabel'
E               - invalid_alabel
E               + non_canonical_alabel

tests/test_idna_errors.py:94: AssertionError
=========================== short test summary info ============================
SUBFAILED(label='xn---bbk') tests/test_idna.py::IDNATests::test_non_canonical_alabel
SUBFAILED(label=b'xn---bbk') tests/test_idna.py::IDNATests::test_non_canonical_alabel
SUBFAILED(label='XN---BBK') tests/test_idna.py::IDNATests::test_non_canonical_alabel
SUBFAILED(code='non_canonical_alabel') tests/test_idna_errors.py::ErrorAttributeTests::test_every_error_code_is_raisable

https://docs.python.org/3.16/whatsnew/3.16.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.16/fedora-rawhide-x86_64/11359655-python-idna/

For all our attempts to build python-idna with Python 3.16, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.16/package/python-idna/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.16:
https://copr.fedorainfracloud.org/coprs/g/python/python3.16/

Let us know here if you have any questions.

Python 3.16 is planned to be included in Fedora 47.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.16.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.