Repository: pyqtgraph/pyqtgraph

Issue:
Unicode calls when saving and loading flowcharts fail on Python 3
[`Flowchart.saveFile`](https://github.com/pyqtgraph/pyqtgraph/blob/develop/pyqtgraph/flowchart/Flowchart.py#L538) and [`Flowchart.loadFile`](https://github.com/pyqtgraph/pyqtgraph/blob/develop/pyqtgraph/flowchart/Flowchart.py#L517) both contain raw calls to `unicode` that have not been updated to use the python 2/3 compatibility library. These calls should be replaced by [`python2_3.asUnicode`](https://github.com/pyqtgraph/pyqtgraph/blob/develop/pyqtgraph/python2_3.py#L6).

`FlowchartCtrlWidget` has similar issues in its `fileSaved` and `setCurrentFile` methods too.


Discussion:

Resolving patch:
diff --git a/pyqtgraph/flowchart/Flowchart.py b/pyqtgraph/flowchart/Flowchart.py
--- a/pyqtgraph/flowchart/Flowchart.py
+++ b/pyqtgraph/flowchart/Flowchart.py
@@ -27,6 +27,7 @@
 from .. import dockarea as dockarea
 from . import FlowchartGraphicsView
 from .. import functions as fn
+from ..python2_3 import asUnicode
 
 def strDict(d):
     return dict([(str(k), v) for k, v in d.items()])
@@ -519,12 +520,12 @@ def loadFile(self, fileName=None, startDir=None):
             self.fileDialog.fileSelected.connect(self.loadFile)
             return
             ## NOTE: was previously using a real widget for the file dialog's parent, but this caused weird mouse event bugs..
-        fileName = unicode(fileName)
+        fileName = asUnicode(fileName)
         state = configfile.readConfigFile(fileName)
         self.restoreState(state, clear=True)
         self.viewBox.autoRange()
         self.sigFileLoaded.emit(fileName)
-        
+
     def saveFile(self, fileName=None, startDir=None, suggestedFileName='flowchart.fc'):
         """Save this flowchart to a .fc file
         """
@@ -534,11 +535,12 @@ def saveFile(self, fileName=None, startDir=None, suggestedFileName='flowchart.fc
             if startDir is None:
                 startDir = '.'
             self.fileDialog = FileDialog(None, "Save Flowchart..", startDir, "Flowchart (*.fc)")
+            self.fileDialog.setDefaultSuffix("fc")
             self.fileDialog.setAcceptMode(QtGui.QFileDialog.AcceptSave) 
             self.fileDialog.show()
             self.fileDialog.fileSelected.connect(self.saveFile)
             return
-        fileName = unicode(fileName)
+        fileName = asUnicode(fileName)
         configfile.writeConfigFile(self.saveState(), fileName)
         self.sigFileSaved.emit(fileName)
 
@@ -662,7 +664,7 @@ def loadClicked(self):
         #self.setCurrentFile(newFile)
         
     def fileSaved(self, fileName):
-        self.setCurrentFile(unicode(fileName))
+        self.setCurrentFile(asUnicode(fileName))
         self.ui.saveBtn.success("Saved.")
         
     def saveClicked(self):
@@ -691,7 +693,7 @@ def saveAsClicked(self):
         #self.setCurrentFile(newFile)
             
     def setCurrentFile(self, fileName):
-        self.currentFileName = unicode(fileName)
+        self.currentFileName = asUnicode(fileName)
         if fileName is None:
             self.ui.fileNameLabel.setText("<b>[ new ]</b>")
         else:
diff --git a/pyqtgraph/flowchart/Node.py b/pyqtgraph/flowchart/Node.py
--- a/pyqtgraph/flowchart/Node.py
+++ b/pyqtgraph/flowchart/Node.py
@@ -373,7 +373,7 @@ def saveState(self):
         pos = self.graphicsItem().pos()
         state = {'pos': (pos.x(), pos.y()), 'bypass': self.isBypassed()}
         termsEditable = self._allowAddInput | self._allowAddOutput
-        for term in self._inputs.values() + self._outputs.values():
+        for term in list(self._inputs.values()) + list(self._outputs.values()):
             termsEditable |= term._renamable | term._removable | term._multiable
         if termsEditable:
             state['terminals'] = self.saveTerminals()


Test patch: