Bug 2259529

Summary: python-pycountry fails to build with Python 3.13: AssertionError: assert 'FR-FR-ARA' == 'FR-ARA'
Product: [Fedora] Fedora Reporter: Karolina Surma <ksurma>
Component: python-pycountryAssignee: Elliott Sales de Andrade <quantum.analyst>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: code, ksurma, mhroncok, python-packagers-sig, quantum.analyst
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-02-07 02:02:41 UTC 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: 2244836    

Description Karolina Surma 2024-01-22 08:39:05 UTC
python-pycountry fails to build with Python 3.13.0a3.

+ /usr/bin/pytest --pyargs pycountry
============================= test session starts ==============================
platform linux -- Python 3.13.0a3, pytest-7.4.3, pluggy-1.3.0
rootdir: /builddir/build/BUILD/pycountry-22.3.5
collected 21 items

tests/test_general.py .....F...........F...                              [100%]

=================================== FAILURES ===================================
_________________ test_subdivisions_have_subdivision_as_parent _________________

    def test_subdivisions_have_subdivision_as_parent():
        fr_01 = pycountry.subdivisions.get(code="FR-01")
        assert fr_01.code == "FR-01"
        assert fr_01.name == "Ain"
        assert fr_01.type == "Metropolitan department"
>       assert fr_01.parent_code == "FR-ARA"
E       AssertionError: assert 'FR-FR-ARA' == 'FR-ARA'
E         - FR-ARA
E         + FR-FR-ARA
E         ? +++

../../BUILDROOT/python-pycountry-22.3.5-8.fc40.x86_64/usr/lib/python3.13/site-packages/pycountry/tests/test_general.py:96: AssertionError
___________________________ test_subdivision_parent ____________________________

    def test_subdivision_parent():
        s = pycountry.subdivisions
        sd = s.get(code="CV-BV")
>       assert sd.parent_code == "CV-B"
E       AssertionError: assert 'CV-CV-B' == 'CV-B'
E         - CV-B
E         + CV-CV-B

../../BUILDROOT/python-pycountry-22.3.5-8.fc40.x86_64/usr/lib/python3.13/site-packages/pycountry/tests/test_general.py:229: AssertionError
=========================== short test summary info ============================
FAILED tests/test_general.py::test_subdivisions_have_subdivision_as_parent - ...
FAILED tests/test_general.py::test_subdivision_parent - AssertionError: asser...
========================= 2 failed, 19 passed in 0.45s =========================

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

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.13/fedora-rawhide-x86_64/06924411-python-pycountry/

For all our attempts to build python-pycountry with Python 3.13, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/package/python-pycountry/

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.13:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/

Let us know here if you have any questions.

Python 3.13 is planned to be included in Fedora 41.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.13.
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.

Comment 1 Ben Beasley 2024-01-31 16:12:24 UTC
I was working on a PR to update to 23.12.11 for python-pydantic-extra-types, so I investigated this.

The regression is caused by https://salsa.debian.org/iso-codes-team/iso-codes/-/commit/5ebe1e8998642087b636e3c104e4735d8925bfe5, which was included in iso-codes 4.16.0. (Rawhide/F40 has it; F39 does not.) Upstream for pycountry still bundles 4.15.0, so they haven’t adapted to this yet, but we unbundle iso-codes, so we must deal with it, ideally by sending upstream a PR to correctly update to 4.16.0.

Comment 2 Ben Beasley 2024-01-31 16:23:49 UTC
Actually, I think https://github.com/pycountry/pycountry/commit/93316463 should fix this. Let’s see.

Comment 3 Ben Beasley 2024-01-31 16:40:16 UTC
(In reply to Ben Beasley from comment #2)
> Actually, I think https://github.com/pycountry/pycountry/commit/93316463
> should fix this. Let’s see.

Yes, backporting that commit works (https://src.fedoraproject.org/rpms/python-pycountry/pull-request/1). I still opened a PR for upstream to update to iso-codes 4.16.0, though: https://github.com/pycountry/pycountry/pull/209