Bug 2447913 - mercurial fails to build with Python 3.15: ImportError: cannot import name 'nlargest' from 'heapq'
Summary: mercurial fails to build with Python 3.15: ImportError: cannot import name 'n...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: mercurial
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Mads Kiilerich
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.15
TreeView+ depends on / blocked
 
Reported: 2026-03-16 10:34 UTC by Karolina Surma
Modified: 2026-03-28 16:42 UTC (History)
8 users (show)

Fixed In Version: mercurial-7.2-2.fc45
Clone Of:
Environment:
Last Closed: 2026-03-28 16:38:01 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

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.


Note You need to log in before you can comment on or make changes to this bug.