Commit c249c3db98ade701f1f177a9c34afe222129fc29
1 parent
caac4beb
Exists in
master
and in
6 other branches
FIX: UnicodeEncodeError when a path in import dialog has non-ascii characters
Showing
1 changed file
with
4 additions
and
2 deletions
Show diff stats
invesalius/gui/dialogs.py
@@ -169,8 +169,10 @@ def ShowImportDirDialog(): | @@ -169,8 +169,10 @@ def ShowImportDirDialog(): | ||
169 | 169 | ||
170 | path = None | 170 | path = None |
171 | if dlg.ShowModal() == wx.ID_OK: | 171 | if dlg.ShowModal() == wx.ID_OK: |
172 | - path = dlg.GetPath() | ||
173 | - | 172 | + # GetPath returns in unicode, if a path has non-ascii characters a |
173 | + # UnicodeEncodeError is raised. To avoid this, path is encoded in utf-8 | ||
174 | + path = dlg.GetPath().encode('utf-8') | ||
175 | + | ||
174 | # Only destroy a dialog after you're done with it. | 176 | # Only destroy a dialog after you're done with it. |
175 | dlg.Destroy() | 177 | dlg.Destroy() |
176 | os.chdir(current_dir) | 178 | os.chdir(current_dir) |