Bug 1902381

Summary: python-mplcursors fails to build with Python 3.10: RuntimeError: dictionary changed size during iteration
Product: [Fedora] Fedora Reporter: Miro Hrončok <mhroncok>
Component: python-mplcursorsAssignee: Elliott Sales de Andrade <quantum.analyst>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: mhroncok, python-sig, quantum.analyst, thrnciar
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: 2021-02-06 05:47:22 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: 1890881    

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.