🌐 AI搜索 & 代理 主页
Skip to content

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

@mgorny

Description

@mgorny

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

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