Commit 03ae2d2fa0bd092ba7fe69c8bbbe423efaffcf60
1 parent
6a9556a5
Exists in
master
and in
68 other branches
ENH: Handling a unicode error in session
Showing
1 changed file
with
5 additions
and
1 deletions
Show diff stats
invesalius/session.py
| 1 | import ConfigParser | 1 | import ConfigParser |
| 2 | import os | 2 | import os |
| 3 | import shutil | 3 | import shutil |
| 4 | +import sys | ||
| 4 | from threading import Thread | 5 | from threading import Thread |
| 5 | import time | 6 | import time |
| 6 | 7 | ||
| @@ -138,7 +139,10 @@ class Session(object): | @@ -138,7 +139,10 @@ class Session(object): | ||
| 138 | config.add_section('paths') | 139 | config.add_section('paths') |
| 139 | config.set('paths','homedir',self.homedir) | 140 | config.set('paths','homedir',self.homedir) |
| 140 | config.set('paths','tempdir',self.tempdir) | 141 | config.set('paths','tempdir',self.tempdir) |
| 141 | - config.set('paths','last_dicom_folder',self.last_dicom_folder.encode('utf-8')) | 142 | + try: |
| 143 | + config.set('paths','last_dicom_folder',self.last_dicom_folder.encode('utf-8')) | ||
| 144 | + except (UnicodeEncodeError, UnicodeDecodeError): | ||
| 145 | + config.set('paths','last_dicom_folder',self.last_dicom_folder) | ||
| 142 | path = os.path.join(self.homedir , | 146 | path = os.path.join(self.homedir , |
| 143 | '.invesalius', 'config.cfg') | 147 | '.invesalius', 'config.cfg') |
| 144 | 148 |