You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
issues with unicode_literals and pysides.QtCore.Slot #2378
tcaswell@mara:~$ ipython --pylab
Python 2.7.5+ (default, Aug 4 2013, 10:07:17)
Type "copyright", "credits" or "license" for more information.
IPython 2.0.0-dev -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
Segmentation fault
git bisect points me to commit f4adec7 as the first bad commit.
It works (that is, does not seg-fault) if pyqt is used instead.
I spent a bit of time trying to track down exactly where it was blowing up and it seems to bad a bad interaction between from __future__ import unicode_literals and the pyside version of @QtCore.Slot().
And it looks like the 'fix' is to convert all of the Qt calls to new style calls.
If we look at the top of backend.qt4_editor/formlayout.py (which just happens to be the first place that @QtCore.Slot() is encountered when importing stuff) if we change it to:
from __future__ import absolute_import, division, print_function, unicode_literals
import six
from six.moves import xrange
# History:
# 1.0.10: added float validator (disable "Ok" and "Apply" button when not valid)
# 1.0.7: added support for "Apply" button
# 1.0.6: code cleaning
__version__ = '1.0.10'
__license__ = __doc__
DEBUG = False
import sys
STDERR = sys.stderr
from matplotlib.colors import is_color_like
from matplotlib.colors import rgb2hex
from matplotlib.colors import colorConverter
from matplotlib.backends.qt4_compat import QtGui, QtCore
if not hasattr(QtGui, 'QFormLayout'):
raise ImportError("Warning: formlayout requires PyQt4 >v4.3 or PySide")
import datetime
class ColorButton(QtGui.QPushButton):
"""
Color choosing push button
"""
# __pyqtSignals__ = ("colorChanged(QColor)",)
def __init__(self, parent=None):
QtGui.QPushButton.__init__(self, parent)
self.setFixedSize(20, 20)
self.setIconSize(QtCore.QSize(12, 12))
# self.connect(self, QtCore.SIGNAL("clicked()"), self.choose_color)
self._color = QtGui.QColor()
def choose_color(self):
color = QtGui.QColorDialog.getColor(self._color,self.parentWidget(),'')
if color.isValid():
self.set_color(color)
def get_color(self):
return self._color
@QtCore.Slot(QtGui.QColor)
def set_color(self, color):
if color != self._color:
self._color = color
# self.emit(QtCore.SIGNAL("colorChanged(QColor)"), self._color)
pixmap = QtGui.QPixmap(self.iconSize())
pixmap.fill(color)
self.setIcon(QtGui.QIcon(pixmap))
color = QtCore.Property(QtGui.QColor, get_color, set_color)
Sorry for having a conversation with my self, but it doesn't look too bad to (only ~34 lines need to be changed in only two files (backend_qt4.py and formlayout.py). I will take a crack at this tonight.
Activity
tacaswell commentedon Sep 4, 2013
also see https://code.google.com/p/spyderlib/issues/detail?id=1466 -> discussion at -https://code.google.com/p/spyderlib/source/detail?r=d12c3026caee -> https://bugreports.qt-project.org/browse/PYSIDE-100
so it looks like this is long standing but unfixed upstream issue.
tacaswell commentedon Sep 4, 2013
And it looks like the 'fix' is to convert all of the Qt calls to new style calls.
If we look at the top of
backend.qt4_editor/formlayout.py(which just happens to be the first place that@QtCore.Slot()is encountered when importing stuff) if we change it to:It does not segfault.
tacaswell commentedon Sep 4, 2013
Sorry for having a conversation with my self, but it doesn't look too bad to (only ~34 lines need to be changed in only two files (
backend_qt4.pyandformlayout.py). I will take a crack at this tonight.mdboom commentedon Sep 4, 2013
Great. The change to not using 2to3 was just merged yesterday, and I'm glad it's already getting its tyres kicked, and thanks for finding a solution.
mdboom commentedon Sep 4, 2013
@tacaswell: Thanks. Sorry for the speedbump, but I think we're going to prefer not running 2to3 anymore in the long run.
converted import-critical PyQt calls to new style so that it will