Bug 1902381 - python-mplcursors fails to build with Python 3.10: RuntimeError: dictionary changed size during iteration
Summary: python-mplcursors fails to build with Python 3.10: RuntimeError: dictionary c...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: python-mplcursors
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Elliott Sales de Andrade
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.10
TreeView+ depends on / blocked
 
Reported: 2020-11-28 10:05 UTC by Miro Hrončok
Modified: 2021-02-06 05:47 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-02-06 05:47:22 UTC
Type: Bug


Attachments (Terms of Use)

Description Miro Hrončok 2020-11-28 10:05:08 UTC
python-mplcursors fails to build with Python 3.10.0a2.

______________________________ test_remove_cursor ______________________________

ax = <AxesSubplot:>

    def test_remove_cursor(ax):
        ax.plot([0, 1])
        cursor = mplcursors.cursor()
>       _process_event("__mouse_click__", ax, (.5, .5), 1)

tests/test_mplcursors.py:579: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_mplcursors.py:63: in _process_event
    _process_event("button_press_event", ax, coords, *args)
tests/test_mplcursors.py:74: in _process_event
    ax.figure.canvas.callbacks.process(name, event)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <matplotlib.cbook.CallbackRegistry object at 0x7fa35a1cb850>
s = 'button_press_event'
args = (<matplotlib.backend_bases.MouseEvent object at 0x7fa350ddde80>,)
kwargs = {}

    def process(self, s, *args, **kwargs):
        """
        Process signal *s*.
    
        All of the functions registered to receive callbacks on *s* will be
        called with ``*args`` and ``**kwargs``.
        """
>       for cid, ref in list(self.callbacks.get(s, {}).items()):
E       RuntimeError: dictionary changed size during iteration

/usr/lib64/python3.10/site-packages/matplotlib/cbook/__init__.py:220: RuntimeError

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.10/fedora-rawhide-x86_64/01797325-python-mplcursors/

For all our attempts to build python-mplcursors with Python 3.10, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/package/python-mplcursors/

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

Let us know here if you have any questions.

Python 3.10 will be included in Fedora 35. To make that update smoother, we're building Fedora packages with early pre-releases of Python 3.10.
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 Elliott Sales de Andrade 2020-11-28 23:57:23 UTC
What dictionary? There's a list() around the .items(), so it should be a copy, even if it was modified.

The result of `self.callbacks.get(s, {})` is a dictionary of int -> weakref of function. When that weakref dies, it does go through a remove function that deletes things from the dictionaries, but that function also does a list() so should avoid changing during iteration.

Comment 2 Miro Hrončok 2020-11-29 00:48:48 UTC
> What dictionary? 

My thoughts exactly. No idea :(

Comment 3 Elliott Sales de Andrade 2021-02-06 05:47:22 UTC
Despite Python crashing now, the build appears to have been fixed for a few weeks.


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