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 | 1 | import ConfigParser |
| 2 | 2 | import os |
| 3 | 3 | import shutil |
| 4 | +import sys | |
| 4 | 5 | from threading import Thread |
| 5 | 6 | import time |
| 6 | 7 | |
| ... | ... | @@ -138,7 +139,10 @@ class Session(object): |
| 138 | 139 | config.add_section('paths') |
| 139 | 140 | config.set('paths','homedir',self.homedir) |
| 140 | 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 | 146 | path = os.path.join(self.homedir , |
| 143 | 147 | '.invesalius', 'config.cfg') |
| 144 | 148 | ... | ... |