Skip to content

Using matplotlib 2.1.0rc1 seems to corrupt PySide #9162

Closed
@vallsv

Description

@vallsv

Bug report

Bug summary

Hi. We are using CI of our project with PySide and pre releases of matplotlib. We notice that since 2.1.0rc1 all our tests fails with this kind or error message:

TypeError: PySide.QtCore.QObject isn't a direct base class of ClassBlahblahblah

After introspection we think that the problem come from matplotlib 2.1.0rc1, but it was too difficult to identify why. Using the previour version of matplotlib does not occur any problem.

The problem looks critical.

Any idea why this issue happens?

Code for reproduction

import logging
logging.basicConfig()
from PySide import QtGui

logger = logging.getLogger("test")

app = QtGui.QApplication([])

class Foo_super(QtGui.QWidget):
    def __init__(self, parent=None):
        super(Foo_super, self).__init__(parent)

class Foo_oldschool(QtGui.QWidget):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)

import matplotlib
matplotlib.use('Qt4Agg')
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure

fig = Figure(figsize=(600,600), dpi=72, facecolor=(1,1,1), edgecolor=(0,0,0))
ax = fig.add_subplot(111)
ax.plot([0,1])

try:
    a = Foo_super()
except Exception as e:
    logger.error("Backtrace 1", exc_info=True)
try:
    a = Foo_oldschool()
except Exception as e:
    logger.error("Backtrace 2", exc_info=True)

canvas = FigureCanvas(fig)

try:
    a = Foo_super()
except Exception as e:
    logger.error("Backtrace 3", exc_info=True)
try:
    a = Foo_oldschool()
except Exception as e:
    logger.error("Backtrace 4", exc_info=True)

Actual outcome

ERROR:test:Backtrace 3
Traceback (most recent call last):
  File "test_matplotlib_vs_pyside.py", line 47, in <module>
    a = Foo_super()
  File "test_matplotlib_vs_pyside.py", line 14, in __init__
    super(Foo_super, self).__init__(parent)
TypeError: PySide.QtCore.QObject isn't a direct base class of Foo_super
ERROR:test:Backtrace 4
Traceback (most recent call last):
  File "test_matplotlib_vs_pyside.py", line 52, in <module>
    a = Foo_oldschool()
  File "test_matplotlib_vs_pyside.py", line 19, in __init__
    QtGui.QWidget.__init__(self, parent)
TypeError: PySide.QtCore.QObject isn't a direct base class of Foo_oldschool

Expected outcome

As you can see, after the use of canvas = FigureCanvas(fig), we are not able anymore to instantiate a very simple custom widget. Using old or new way to call inherited __init__ do not change anything.

Matplotlib version

Our CI is on Windows.

But I can reproduce it on my system with a fresh virtualenv, compiling everything using pip: numpy, matplotlib and PySide.

  • Operating System: Debian 8
  • Matplotlib Version: 2.1.0rc1
  • Python Version: Python 2.7.9
  • Other Libraries:
Package                            Version 
---------------------------------- --------
backports.functools-lru-cache      1.4     
backports.shutil-get-terminal-size 1.0.0   
cycler                             0.10.0  
decorator                          4.1.2   
enum34                             1.1.6   
ipython                            5.4.1   
ipython-genutils                   0.2.0   
matplotlib                         2.1.0rc1
numpy                              1.13.1  
pathlib2                           2.3.0   
pexpect                            4.2.1   
pickleshare                        0.7.4   
pip                                9.0.1   
prompt-toolkit                     1.0.15  
ptyprocess                         0.5.2   
Pygments                           2.2.0   
pyparsing                          2.2.0   
PySide                             1.2.4   
python-dateutil                    2.6.1   
pytz                               2017.2  
scandir                            1.5     
setuptools                         36.4.0  
simplegeneric                      0.8.1   
six                                1.10.0  
subprocess32                       3.2.7   
traitlets                          4.3.2   
wcwidth                            0.1.7   
wheel                              0.30.0a0
  • There is no problem with the same environment and using matplotlib 2.0.0 or 2.0.2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions