Преглед на файлове

wxGUI: Remove calls of unicode function which don't work in Python 3 (#1111)

This removes all direct calls of unicode() function which is not present in Python 3.

The str() function is used instead to convert from exceptions/errors to strings.
The column iteration works without any conversion in Python 3.

Additionally, this renames variables e to error and removes a todo note to
fix exceptional case in a better way (not clear enough to be useful).
Vaclav Petras преди 4 години
родител
ревизия
2440ec1ff7
променени са 5 файла, в които са добавени 10 реда и са изтрити 10 реда
  1. 1 1
      gui/wxpython/core/gconsole.py
  2. 1 1
      gui/wxpython/dbmgr/sqlbuilder.py
  3. 2 2
      gui/wxpython/gui_core/prompt.py
  4. 2 2
      gui/wxpython/modules/extensions.py
  5. 4 4
      gui/wxpython/timeline/frame.py

+ 1 - 1
gui/wxpython/core/gconsole.py

@@ -493,7 +493,7 @@ class GConsole(wx.EvtHandler):
                     task = GUI(show=None).ParseCommand(command)
                     task = GUI(show=None).ParseCommand(command)
                 except GException as e:
                 except GException as e:
                     GError(parent=self._guiparent,
                     GError(parent=self._guiparent,
-                           message=unicode(e),
+                           message=str(e),
                            showTraceback=False)
                            showTraceback=False)
                     return
                     return
 
 

+ 1 - 1
gui/wxpython/dbmgr/sqlbuilder.py

@@ -802,7 +802,7 @@ class SQLBuilderUpdate(SQLBuilder):
                     colstr = sqlstr[idx1:].strip()
                     colstr = sqlstr[idx1:].strip()
 
 
                 cols = [col.split('=')[0].strip() for col in colstr.split(',')]
                 cols = [col.split('=')[0].strip() for col in colstr.split(',')]
-                if unicode(value) in cols:
+                if value in cols:
                     self.text_sql.SetInsertionPoint(curspos)
                     self.text_sql.SetInsertionPoint(curspos)
                     wx.CallAfter(self.text_sql.SetFocus)
                     wx.CallAfter(self.text_sql.SetFocus)
                     return
                     return

+ 2 - 2
gui/wxpython/gui_core/prompt.py

@@ -468,9 +468,9 @@ class GPromptSTC(GPrompt, wx.stc.StyledTextCtrl):
                                     self.toComplete['cmd']).count('.')
                                     self.toComplete['cmd']).count('.')
                                 self.autoCompList.append(
                                 self.autoCompList.append(
                                     command.split('.', dotNumber)[-1])
                                     command.split('.', dotNumber)[-1])
-                        except UnicodeDecodeError as e:  # TODO: fix it
+                        except UnicodeDecodeError as error:
                             sys.stderr.write(
                             sys.stderr.write(
-                                DecodeString(command) + ": " + unicode(e))
+                                DecodeString(command) + ": " + str(error))
 
 
             except (KeyError, TypeError):
             except (KeyError, TypeError):
                 return
                 return

+ 2 - 2
gui/wxpython/modules/extensions.py

@@ -215,9 +215,9 @@ class InstallExtensionWindow(wx.Frame):
                 callable=self.modelBuilder.Load,
                 callable=self.modelBuilder.Load,
                 url='', # self.repo.GetValue().strip(),
                 url='', # self.repo.GetValue().strip(),
                 ondone=lambda event: self._fetchDone())
                 ondone=lambda event: self._fetchDone())
-        except GException as e:
+        except GException as error:
             self._fetchDone()
             self._fetchDone()
-            GError(unicode(e), parent=self, showTraceback=False)
+            GError(str(error), parent=self, showTraceback=False)
 
 
     def _fetchDone(self):
     def _fetchDone(self):
         self.tree.RefreshItems()
         self.tree.RefreshItems()

+ 4 - 4
gui/wxpython/timeline/frame.py

@@ -397,8 +397,8 @@ class TimelineFrame(wx.Frame):
             datasets = self._checkDatasets(datasets)
             datasets = self._checkDatasets(datasets)
             if not datasets:
             if not datasets:
                 return
                 return
-        except GException as e:
-            GError(parent=self, message=unicode(e), showTraceback=False)
+        except GException as error:
+            GError(parent=self, message=str(error), showTraceback=False)
             return
             return
 
 
         self.datasets = datasets
         self.datasets = datasets
@@ -509,8 +509,8 @@ class TimelineFrame(wx.Frame):
             datasets = self._checkDatasets(datasets)
             datasets = self._checkDatasets(datasets)
             if not datasets:
             if not datasets:
                 return
                 return
-        except GException as e:
-            GError(parent=self, message=unicode(e), showTraceback=False)
+        except GException as error:
+            GError(parent=self, message=str(error), showTraceback=False)
             return
             return
         self.datasets = datasets
         self.datasets = datasets
         self.datasetSelect.SetValue(
         self.datasetSelect.SetValue(