Bug 2447913

Summary: mercurial fails to build with Python 3.15: ImportError: cannot import name 'nlargest' from 'heapq'
Product: [Fedora] Fedora Reporter: Karolina Surma <ksurma>
Component: mercurialAssignee: Mads Kiilerich <mads>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: fedoraproject.org, ksurma, lbalhar, mads, mhroncok, ndbecker2, opohorel, pstodulk
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: mercurial-7.2-2.fc45 Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2026-03-28 16:38:01 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: 2412434    

Description Karolina Surma 2026-03-16 10:34:10 UTC
mercurial fails to build with Python 3.15.0a7.

+ make install-doc DESTDIR=/builddir/build/BUILD/mercurial-7.2-build/BUILDROOT MANDIR=/usr/share/man
make -C doc  PREFIX="/usr/local"  install
make[1]: Entering directory '/builddir/build/BUILD/mercurial-7.2-build/mercurial-7.2/doc'
python3 gendoc.py  commandlist > commandlist.txt.tmp
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 1261, in _find_and_load_unlocked
ImportError: deferred import of 'heapq.nlargest' raised an exception during resolution

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/builddir/build/BUILD/mercurial-7.2-build/mercurial-7.2/doc/gendoc.py", line 48, in <module>
    initialization.init()
    ^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib.util>", line 208, in __getattribute__
  File "<frozen importlib._bootstrap_external>", line 747, in exec_module
  File "<frozen importlib._bootstrap>", line 491, in _call_with_frames_removed
  File "/builddir/build/BUILD/mercurial-7.2-build/mercurial-7.2/mercurial/initialization.py", line 76, in <module>
    bundle2_part_handlers.init()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib.util>", line 208, in __getattribute__
  File "<frozen importlib._bootstrap_external>", line 747, in exec_module
  File "<frozen importlib._bootstrap>", line 491, in _call_with_frames_removed
  File "/builddir/build/BUILD/mercurial-7.2-build/mercurial-7.2/mercurial/bundle2_part_handlers.py", line 79, in <module>
    @parthandler(
     ~~~~~~~~~~~^
        b'changegroup',
        ^^^^^^^^^^^^^^^
    ...<7 lines>...
        ),
        ^^
    )
    ^
  File "/builddir/build/BUILD/mercurial-7.2-build/mercurial-7.2/mercurial/bundle2_part_handlers.py", line 67, in parthandler
    bundle2.validateparttype(parttype)
    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib.util>", line 208, in __getattribute__
  File "<frozen importlib._bootstrap_external>", line 747, in exec_module
  File "<frozen importlib._bootstrap>", line 491, in _call_with_frames_removed
  File "/builddir/build/BUILD/mercurial-7.2-build/mercurial-7.2/mercurial/bundle2.py", line 2049, in <module>
    class AbortFromPart(error.Abort):
                        ^^^^^^^^^^^
  File "<frozen importlib.util>", line 208, in __getattribute__
  File "<frozen importlib._bootstrap_external>", line 747, in exec_module
  File "<frozen importlib._bootstrap>", line 491, in _call_with_frames_removed
  File "/builddir/build/BUILD/mercurial-7.2-build/mercurial-7.2/mercurial/error.py", line 16, in <module>
    import difflib
  File "<frozen importlib.util>", line 208, in __getattribute__
  File "/usr/lib64/python3.15/difflib.py", line 34, in <module>
    from heapq import nlargest as _nlargest
ImportError: cannot import name 'nlargest' from 'heapq' (/usr/lib64/python3.15/heapq.py)
python3 gendoc.py  "hg-ssh.8" > hg-ssh.8.txt.tmp
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 1261, in _find_and_load_unlocked
ImportError: deferred import of 'heapq.nlargest' raised an exception during resolution

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/builddir/build/BUILD/mercurial-7.2-build/mercurial-7.2/doc/gendoc.py", line 48, in <module>
    initialization.init()
    ^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib.util>", line 208, in __getattribute__
  File "<frozen importlib._bootstrap_external>", line 747, in exec_module
  File "<frozen importlib._bootstrap>", line 491, in _call_with_frames_removed
  File "/builddir/build/BUILD/mercurial-7.2-build/mercurial-7.2/mercurial/initialization.py", line 76, in <module>
    bundle2_part_handlers.init()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib.util>", line 208, in __getattribute__
  File "<frozen importlib._bootstrap_external>", line 747, in exec_module
  File "<frozen importlib._bootstrap>", line 491, in _call_with_frames_removed
  File "/builddir/build/BUILD/mercurial-7.2-build/mercurial-7.2/mercurial/bundle2_part_handlers.py", line 79, in <module>
    @parthandler(
     ~~~~~~~~~~~^
        b'changegroup',
        ^^^^^^^^^^^^^^^
    ...<7 lines>...
        ),
        ^^
    )
    ^
  File "/builddir/build/BUILD/mercurial-7.2-build/mercurial-7.2/mercurial/bundle2_part_handlers.py", line 67, in parthandler
    bundle2.validateparttype(parttype)
    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib.util>", line 208, in __getattribute__
  File "<frozen importlib._bootstrap_external>", line 747, in exec_module
  File "<frozen importlib._bootstrap>", line 491, in _call_with_frames_removed
  File "/builddir/build/BUILD/mercurial-7.2-build/mercurial-7.2/mercurial/bundle2.py", line 2049, in <module>
    class AbortFromPart(error.Abort):
                        ^^^^^^^^^^^
  File "<frozen importlib.util>", line 208, in __getattribute__
  File "<frozen importlib._bootstrap_external>", line 747, in exec_module
  File "<frozen importlib._bootstrap>", line 491, in _call_with_frames_removed
  File "/builddir/build/BUILD/mercurial-7.2-build/mercurial-7.2/mercurial/error.py", line 16, in <module>
    import difflib
  File "<frozen importlib.util>", line 208, in __getattribute__
  File "/usr/lib64/python3.15/difflib.py", line 34, in <module>
    from heapq import nlargest as _nlargest
ImportError: cannot import name 'nlargest' from 'heapq' (/usr/lib64/python3.15/heapq.py)

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

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.15/fedora-rawhide-x86_64/10222339-mercurial/

For all our attempts to build mercurial with Python 3.15, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.15/package/mercurial/

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

Let us know here if you have any questions.

Python 3.15 is planned to be included in Fedora 45.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.15.
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 2 Fedora Update System 2026-03-28 16:40:19 UTC
FEDORA-2026-c8f1778c50 (mercurial-7.2-2.fc45) has been submitted as an update to Fedora 45.
https://bodhi.fedoraproject.org/updates/FEDORA-2026-c8f1778c50

Comment 3 Fedora Update System 2026-03-28 16:42:51 UTC
FEDORA-2026-c8f1778c50 (mercurial-7.2-2.fc45) has been pushed to the Fedora 45 stable repository.
If problem still persists, please make note of it in this bug report.