Skip to content

Commit

Permalink
wxGUI: Remove calls of unicode function which don't work in Python 3 (#…
Browse files Browse the repository at this point in the history
…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).
  • Loading branch information
wenzeslaus authored and neteler committed Dec 6, 2020
1 parent d4cc639 commit 2440ec1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gui/wxpython/core/gconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ def RunCmd(self, command, compReg=True, env=None, skipInterface=False,
task = GUI(show=None).ParseCommand(command)
except GException as e:
GError(parent=self._guiparent,
message=unicode(e),
message=str(e),
showTraceback=False)
return

Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/dbmgr/sqlbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ def _add(self, element, value):
colstr = sqlstr[idx1:].strip()

cols = [col.split('=')[0].strip() for col in colstr.split(',')]
if unicode(value) in cols:
if value in cols:
self.text_sql.SetInsertionPoint(curspos)
wx.CallAfter(self.text_sql.SetFocus)
return
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/gui_core/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,9 @@ def OnChar(self, event):
self.toComplete['cmd']).count('.')
self.autoCompList.append(
command.split('.', dotNumber)[-1])
except UnicodeDecodeError as e: # TODO: fix it
except UnicodeDecodeError as error:
sys.stderr.write(
DecodeString(command) + ": " + unicode(e))
DecodeString(command) + ": " + str(error))

except (KeyError, TypeError):
return
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/modules/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ def _fetch(self):
callable=self.modelBuilder.Load,
url='', # self.repo.GetValue().strip(),
ondone=lambda event: self._fetchDone())
except GException as e:
except GException as error:
self._fetchDone()
GError(unicode(e), parent=self, showTraceback=False)
GError(str(error), parent=self, showTraceback=False)

def _fetchDone(self):
self.tree.RefreshItems()
Expand Down
8 changes: 4 additions & 4 deletions gui/wxpython/timeline/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ def OnRedraw(self, event):
datasets = self._checkDatasets(datasets)
if not datasets:
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

self.datasets = datasets
Expand Down Expand Up @@ -509,8 +509,8 @@ def SetDatasets(self, datasets):
datasets = self._checkDatasets(datasets)
if not datasets:
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
self.datasets = datasets
self.datasetSelect.SetValue(
Expand Down

0 comments on commit 2440ec1

Please sign in to comment.