Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 016f568

Browse files
committed
Merge pull request #4278 from mfitzp/pyqt4-api1-py3-compat
MNT : Replace use of str() with six.text_type() for Py2&3 compatibility
1 parent 592818a commit 016f568

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/matplotlib/backends/backend_qt5.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def _create_qApp():
137137
if display is None or not re.search(':\d', display):
138138
raise RuntimeError('Invalid DISPLAY variable')
139139

140-
qApp = QtWidgets.QApplication([str(" ")])
140+
qApp = QtWidgets.QApplication([six.text_type(" ")])
141141
qApp.lastWindowClosed.connect(qApp.quit)
142142
else:
143143
qApp = app
@@ -557,7 +557,7 @@ def destroy(self, *args):
557557
self.window.close()
558558

559559
def get_window_title(self):
560-
return str(self.window.windowTitle())
560+
return six.text_type(self.window.windowTitle())
561561

562562
def set_window_title(self, title):
563563
self.window.setWindowTitle(title)
@@ -730,7 +730,7 @@ def save_figure(self, *args):
730730
self.canvas.print_figure(six.text_type(fname))
731731
except Exception as e:
732732
QtWidgets.QMessageBox.critical(
733-
self, "Error saving file", str(e),
733+
self, "Error saving file", six.text_type(e),
734734
QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.NoButton)
735735

736736

@@ -846,7 +846,7 @@ def exception_handler(type, value, tb):
846846
if hasattr(value, 'strerror') and value.strerror is not None:
847847
msg += value.strerror
848848
else:
849-
msg += str(value)
849+
msg += six.text_type(value)
850850

851851
if len(msg):
852852
error_msg_qt(msg)

0 commit comments

Comments
 (0)