FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[TST] test_backends_interactive.py::test_figure_leak_20490 failures with py3.11/PyQt5: AttributeError: 'QShowEvent' object has no attribute 'pos' · Issue #23384 · matplotlib/matplotlib · GitHub

Repository navigation

[TST] test_backends_interactive.py::test_figure_leak_20490 failures with py3.11/PyQt5: AttributeError: 'QShowEvent' object has no attribute 'pos' #23384

Closed

Description

Bug summary

Two tests of the matplotlib's test suite are failing with Python 3.11.0b3:

FAILED tests/test_backends_interactive.py::test_figure_leak_20490[time_mem1-{'MPLBACKEND': 'qtagg', 'QT_API': 'PyQt5'}] - subprocess...
FAILED tests/test_backends_interactive.py::test_figure_leak_20490[time_mem1-{'MPLBACKEND': 'qtcairo', 'QT_API': 'PyQt5'}] - subproce...

Code for reproduction

python3.11 -m pytest -vv --pyargs matplotlib -m "not network"

Actual outcome

============================================================== FAILURES ===============================================================
____________________________ test_figure_leak_20490[time_mem1-{'MPLBACKEND': 'qtagg', 'QT_API': 'PyQt5'}] _____________________________
[gw10] linux -- Python 3.11.0 /tmp/portage/dev-python/matplotlib-3.5.2-r3/work/matplotlib-3.5.2-python3_11/install/usr/bin/python3.11

env = {'MPLBACKEND': 'qtagg', 'QT_API': 'PyQt5'}, time_mem = (0.1, 30000000)

    @pytest.mark.parametrize("env", _get_testable_interactive_backends())
    @pytest.mark.parametrize("time_mem", [(0.0, 2_000_000), (0.1, 30_000_000)])
    def test_figure_leak_20490(env, time_mem):
        pytest.importorskip("psutil", reason="psutil needed to run this test")
    
        # We haven't yet directly identified the leaks so test with a memory growth
        # threshold.
        pause_time, acceptable_memory_leakage = time_mem
        if env["MPLBACKEND"] == "macosx":
            acceptable_memory_leakage += 11_000_000
    
>       result = _run_helper(
            _test_figure_leak, str(pause_time), timeout=_test_timeout, **env
        )

acceptable_memory_leakage = 30000000
env        = {'MPLBACKEND': 'qtagg', 'QT_API': 'PyQt5'}
pause_time = 0.1
time_mem   = (0.1, 30000000)

../matplotlib-3.5.2-python3_11/test-lib/matplotlib/tests/test_backends_interactive.py:464: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../matplotlib-3.5.2-python3_11/test-lib/matplotlib/testing/__init__.py:73: in subprocess_run_helper
    proc = subprocess.run(
        args       = ('0.1',)
        extra_env  = {'MPLBACKEND': 'qtagg', 'QT_API': 'PyQt5'}
        func       = <function _test_figure_leak at 0x7f1c96c19760>
        module     = 'matplotlib.tests.test_backends_interactive'
        target     = '_test_figure_leak'
        timeout    = 60
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

input = None, capture_output = False, timeout = 60, check = True
popenargs = (['/tmp/portage/dev-python/matplotlib-3.5.2-r3/work/matplotlib-3.5.2-python3_11/install/usr/bin/python3.11', '-c', '\nfrom matplotlib.tests.test_backends_interactive import _test_figure_leak\n_test_figure_leak()\n', '0.1'],)
kwargs = {'env': {'A': 'matplotlib-3.5.2.tar.gz freetype-2.6.1.tar.gz', 'ABI': 'amd64', 'ABI_MIPS': '', 'ABI_S390': '', ...}, 'stderr': -1, 'stdout': -1, 'universal_newlines': True}
process = <Popen: returncode: -6 args: ['/tmp/portage/dev-python/matplotlib-3.5.2-r3/w...>, stdout = ''
stderr = 'Traceback (most recent call last):\n  File "/tmp/portage/dev-python/matplotlib-3.5.2-r3/work/matplotlib-3.5.2-python3...                           ^^^^^^^^^^^^^^^^^^^^^^^^^\nAttributeError: \'QShowEvent\' object has no attribute \'pos\'\n'
retcode = -6

    def run(*popenargs,
            input=None, capture_output=False, timeout=None, check=False, **kwargs):
        """Run command with arguments and return a CompletedProcess instance.
    
        The returned instance will have attributes args, returncode, stdout and
        stderr. By default, stdout and stderr are not captured, and those attributes
        will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them.
    
        If check is True and the exit code was non-zero, it raises a
        CalledProcessError. The CalledProcessError object will have the return code
        in the returncode attribute, and output & stderr attributes if those streams
        were captured.
    
        If timeout is given, and the process takes too long, a TimeoutExpired
        exception will be raised.
    
        There is an optional argument "input", allowing you to
        pass bytes or a string to the subprocess's stdin.  If you use this argument
        you may not also use the Popen constructor's "stdin" argument, as
        it will be used internally.
    
        By default, all communication is in bytes, and therefore any "input" should
        be bytes, and the stdout and stderr will be bytes. If in text mode, any
        "input" should be a string, and stdout and stderr will be strings decoded
        according to locale encoding, or by "encoding" if set. Text mode is
        triggered by setting any of text, encoding, errors or universal_newlines.
    
        The other arguments are the same as for the Popen constructor.
        """
        if input is not None:
            if kwargs.get('stdin') is not None:
                raise ValueError('stdin and input arguments may not both be used.')
            kwargs['stdin'] = PIPE
    
        if capture_output:
            if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None:
                raise ValueError('stdout and stderr arguments may not be used '
                                 'with capture_output.')
            kwargs['stdout'] = PIPE
            kwargs['stderr'] = PIPE
    
        with Popen(*popenargs, **kwargs) as process:
            try:
                stdout, stderr = process.communicate(input, timeout=timeout)
            except TimeoutExpired as exc:
                process.kill()
                if _mswindows:
                    # Windows accumulates the output in a single blocking
                    # read() call run on child threads, with the timeout
                    # being done in a join() on those threads.  communicate()
                    # _after_ kill() is required to collect that and add it
                    # to the exception.
                    exc.stdout, exc.stderr = process.communicate()
                else:
                    # POSIX _communicate already populated the output so
                    # far into the TimeoutExpired exception.
                    process.wait()
                raise
            except:  # Including KeyboardInterrupt, communicate handled that.
                process.kill()
                # We don't call process.wait() as .__exit__ does that for us.
                raise
            retcode = process.poll()
            if check and retcode:
>               raise CalledProcessError(retcode, process.args,
                                         output=stdout, stderr=stderr)
E               subprocess.CalledProcessError: Command '['/tmp/portage/dev-python/matplotlib-3.5.2-r3/work/matplotlib-3.5.2-python3_11/install/usr/bin/python3.11', '-c', '\nfrom matplotlib.tests.test_backends_interactive import _test_figure_leak\n_test_figure_leak()\n', '0.1']' died with <Signals.SIGABRT: 6>.

capture_output = False
check      = True
input      = None
kwargs     = {'env': <stripped>,
 'stderr': -1,
 'stdout': -1,
 'universal_newlines': True}
popenargs  = (['/tmp/portage/dev-python/matplotlib-3.5.2-r3/work/matplotlib-3.5.2-python3_11/install/usr/bin/python3.11',
  '-c',
  '\n'
  'from matplotlib.tests.test_backends_interactive import _test_figure_leak\n'
  '_test_figure_leak()\n',
  '0.1'],)
process    = <Popen: returncode: -6 args: ['/tmp/portage/dev-python/matplotlib-3.5.2-r3/w...>
retcode    = -6
stderr     = ('Traceback (most recent call last):\n'
 '  File '
 '"/tmp/portage/dev-python/matplotlib-3.5.2-r3/work/matplotlib-3.5.2-python3_11/test-lib/matplotlib/backends/backend_qt.py", '
 'line 284, in enterEvent\n'
 '    x, y = self.mouseEventCoords(self._get_position(event))\n'
 '                                 ^^^^^^^^^^^^^^^^^^^^^^^^^\n'
 "AttributeError: 'QShowEvent' object has no attribute 'pos'\n")
stdout     = ''
timeout    = 60

/usr/lib/python3.11/subprocess.py:558: CalledProcessError
___________________________ test_figure_leak_20490[time_mem1-{'MPLBACKEND': 'qtcairo', 'QT_API': 'PyQt5'}] ____________________________
[gw2] linux -- Python 3.11.0 /tmp/portage/dev-python/matplotlib-3.5.2-r3/work/matplotlib-3.5.2-python3_11/install/usr/bin/python3.11

env = {'MPLBACKEND': 'qtcairo', 'QT_API': 'PyQt5'}, time_mem = (0.1, 30000000)

    @pytest.mark.parametrize("env", _get_testable_interactive_backends())
    @pytest.mark.parametrize("time_mem", [(0.0, 2_000_000), (0.1, 30_000_000)])
    def test_figure_leak_20490(env, time_mem):
        pytest.importorskip("psutil", reason="psutil needed to run this test")
    
        # We haven't yet directly identified the leaks so test with a memory growth
        # threshold.
        pause_time, acceptable_memory_leakage = time_mem
        if env["MPLBACKEND"] == "macosx":
            acceptable_memory_leakage += 11_000_000
    
>       result = _run_helper(
            _test_figure_leak, str(pause_time), timeout=_test_timeout, **env
        )

acceptable_memory_leakage = 30000000
env        = {'MPLBACKEND': 'qtcairo', 'QT_API': 'PyQt5'}
pause_time = 0.1
time_mem   = (0.1, 30000000)

../matplotlib-3.5.2-python3_11/test-lib/matplotlib/tests/test_backends_interactive.py:464: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../matplotlib-3.5.2-python3_11/test-lib/matplotlib/testing/__init__.py:73: in subprocess_run_helper
    proc = subprocess.run(
        args       = ('0.1',)
        extra_env  = {'MPLBACKEND': 'qtcairo', 'QT_API': 'PyQt5'}
        func       = <function _test_figure_leak at 0x7f8e2ed81760>
        module     = 'matplotlib.tests.test_backends_interactive'
        target     = '_test_figure_leak'
        timeout    = 60
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

input = None, capture_output = False, timeout = 60, check = True
popenargs = (['/tmp/portage/dev-python/matplotlib-3.5.2-r3/work/matplotlib-3.5.2-python3_11/install/usr/bin/python3.11', '-c', '\nfrom matplotlib.tests.test_backends_interactive import _test_figure_leak\n_test_figure_leak()\n', '0.1'],)
kwargs = {'env': {'A': 'matplotlib-3.5.2.tar.gz freetype-2.6.1.tar.gz', 'ABI': 'amd64', 'ABI_MIPS': '', 'ABI_S390': '', ...}, 'stderr': -1, 'stdout': -1, 'universal_newlines': True}
process = <Popen: returncode: -6 args: ['/tmp/portage/dev-python/matplotlib-3.5.2-r3/w...>, stdout = ''
stderr = 'Traceback (most recent call last):\n  File "/tmp/portage/dev-python/matplotlib-3.5.2-r3/work/matplotlib-3.5.2-python3...                           ^^^^^^^^^^^^^^^^^^^^^^^^^\nAttributeError: \'QShowEvent\' object has no attribute \'pos\'\n'
retcode = -6

    def run(*popenargs,
            input=None, capture_output=False, timeout=None, check=False, **kwargs):
        """Run command with arguments and return a CompletedProcess instance.
    
        The returned instance will have attributes args, returncode, stdout and
        stderr. By default, stdout and stderr are not captured, and those attributes
        will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them.
    
        If check is True and the exit code was non-zero, it raises a
        CalledProcessError. The CalledProcessError object will have the return code
        in the returncode attribute, and output & stderr attributes if those streams
        were captured.
    
        If timeout is given, and the process takes too long, a TimeoutExpired
        exception will be raised.
    
        There is an optional argument "input", allowing you to
        pass bytes or a string to the subprocess's stdin.  If you use this argument
        you may not also use the Popen constructor's "stdin" argument, as
        it will be used internally.
    
        By default, all communication is in bytes, and therefore any "input" should
        be bytes, and the stdout and stderr will be bytes. If in text mode, any
        "input" should be a string, and stdout and stderr will be strings decoded
        according to locale encoding, or by "encoding" if set. Text mode is
        triggered by setting any of text, encoding, errors or universal_newlines.
    
        The other arguments are the same as for the Popen constructor.
        """
        if input is not None:
            if kwargs.get('stdin') is not None:
                raise ValueError('stdin and input arguments may not both be used.')
            kwargs['stdin'] = PIPE
    
        if capture_output:
            if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None:
                raise ValueError('stdout and stderr arguments may not be used '
                                 'with capture_output.')
            kwargs['stdout'] = PIPE
            kwargs['stderr'] = PIPE
    
        with Popen(*popenargs, **kwargs) as process:
            try:
                stdout, stderr = process.communicate(input, timeout=timeout)
            except TimeoutExpired as exc:
                process.kill()
                if _mswindows:
                    # Windows accumulates the output in a single blocking
                    # read() call run on child threads, with the timeout
                    # being done in a join() on those threads.  communicate()
                    # _after_ kill() is required to collect that and add it
                    # to the exception.
                    exc.stdout, exc.stderr = process.communicate()
                else:
                    # POSIX _communicate already populated the output so
                    # far into the TimeoutExpired exception.
                    process.wait()
                raise
            except:  # Including KeyboardInterrupt, communicate handled that.
                process.kill()
                # We don't call process.wait() as .__exit__ does that for us.
                raise
            retcode = process.poll()
            if check and retcode:
>               raise CalledProcessError(retcode, process.args,
                                         output=stdout, stderr=stderr)
E               subprocess.CalledProcessError: Command '['/tmp/portage/dev-python/matplotlib-3.5.2-r3/work/matplotlib-3.5.2-python3_11/install/usr/bin/python3.11', '-c', '\nfrom matplotlib.tests.test_backends_interactive import _test_figure_leak\n_test_figure_leak()\n', '0.1']' died with <Signals.SIGABRT: 6>.

capture_output = False
check      = True
input      = None
kwargs     = {'env': <stripped>,
 'stderr': -1,
 'stdout': -1,
 'universal_newlines': True}
popenargs  = (['/tmp/portage/dev-python/matplotlib-3.5.2-r3/work/matplotlib-3.5.2-python3_11/install/usr/bin/python3.11',
  '-c',
  '\n'
  'from matplotlib.tests.test_backends_interactive import _test_figure_leak\n'
  '_test_figure_leak()\n',
  '0.1'],)
process    = <Popen: returncode: -6 args: ['/tmp/portage/dev-python/matplotlib-3.5.2-r3/w...>
retcode    = -6
stderr     = ('Traceback (most recent call last):\n'
 '  File '
 '"/tmp/portage/dev-python/matplotlib-3.5.2-r3/work/matplotlib-3.5.2-python3_11/test-lib/matplotlib/backends/backend_qt.py", '
 'line 284, in enterEvent\n'
 '    x, y = self.mouseEventCoords(self._get_position(event))\n'
 '                                 ^^^^^^^^^^^^^^^^^^^^^^^^^\n'
 "AttributeError: 'QShowEvent' object has no attribute 'pos'\n")
stdout     = ''
timeout    = 60

/usr/lib/python3.11/subprocess.py:558: CalledProcessError

Expected outcome

Passing tests ;-).

Additional information

Testing on top of installed Gentoo packages. These two tests pass with Python 3.10 with the same dependency versions. The traceback looks kinda weird — what I suspect to be happening is that the method gets QShowEvent but is expecting something else but I have no clue why.

Operating system

Gentoo Linux

Matplotlib Version

3.5.2

Matplotlib Backend

(tests use different backends)

Python version

3.11.0b3

Jupyter version

6.4.12

Installation

Linux package manager

Activity

  1. tacaswell commented on Jul 3, 2022

    Member

    It is the exact same Qt and PyQt5 in both cases?

  2. mgorny commented on Jul 4, 2022

    ContributorAuthor

    Yes, it is. The distro package is built identically for all Python versions.

  3. QuLogic commented on Jul 5, 2022

    Member

    This passes for me on Fedora Rawhide with Python 3.11.0b3, Qt qt5-qtbase-5.15.4-4.fc37.x86_64, and PyQt5 python3-qt5-5.15.6-5.fc37.x86_64.

  4. mgorny commented on Jul 5, 2022

    ContributorAuthor

    Qt packages are 5.15.5 here, PyQt5 also 5.15.6.

  5. QuLogic commented on Jul 6, 2022

    Member
    Traceback (most recent call last):
      File
     "/tmp/portage/dev-python/matplotlib-3.5.2-r3/work/matplotlib-3.5.2-python3_11/test-lib/matplotlib/backends/backend_qt.py", line 284, in enterEvent
         x, y = self.mouseEventCoords(self._get_position(event))
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^
     AttributeError: 'QShowEvent' object has no attribute 'pos'
    

    Well, this doesn't seem to make much sense, as enterEvent is an event for "when the mouse enters the widget". A QShowEvent should be handled in a showEvent method instead. Additionally, I'm not even sure how a mouse event would occur as normally one would run tests in Xvfb to allow headless compiles.

    This seems like it's a bug in PyQt, but I don't know how to debug further.

  6. mgorny commented on Jul 7, 2022

    ContributorAuthor

    Yes, the tests are run in Xvfb (apparently we're starting Xvfb with -screen 0 1280x1024x24 +extension RANDR but that predates me). If you have any suggestions what I could do to help, please let me know. I don't really know PyQt at all.

  7. github-actions commented on Dec 15, 2025

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  8. timhoffm commented on Dec 15, 2025

    Member

    Never heard back on this. I assume the issue was somewhere downstream and has been fixed.

  9. mgorny commented on Dec 15, 2025

    ContributorAuthor

    Never heard back on this.

    Heard back on what? The last comment was mine, which was then ignored for 3+ years. Then stable-bot emerged in the middle of the night, and you claim you "never heard back" because I didn't wake up in the middle of the night to answer in the 7 minutes you waited?

    I assume the issue was somewhere downstream and has been fixed.

    No, the issue was "somewhere" upstream and the test has been removed in #27732. I'm sorry for not noticing the issue hasn't been closed then.

  10. timhoffm commented on Dec 15, 2025

    Member

    Sorry, my wording was sloppy. It should have been "No activity and not seen the error for 3 years."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: inactiveMarked by the “Stale” Github Action

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL