From 0b19f6588f3af6ad37ae729640d21e98ea9c9bee Mon Sep 17 00:00:00 2001 From: q Date: Sun, 17 Aug 2014 16:11:51 +0300 Subject: [PATCH] still efforts in difficult chars --- file_list.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/file_list.py b/file_list.py index 747846c..ede022c 100755 --- a/file_list.py +++ b/file_list.py @@ -213,7 +213,15 @@ def get_folder_contents(db,path): files=[] db.execute("SELECT file FROM list where file LIKE ?",(path+'%',)) for row in db: - base=row[0].decode('utf-8').replace(path,'',1) + try: + base=row[0].decode('utf-8').replace(path,'',1) + except UnicodeDecodeError: + print(row[0]+" is giving me trouble.") + try: + base=row[0].encode('utf-8').replace(path,'',1) + except UnicodeDecodeError: + print(row[0]+" is still giving me trouble.") + sys.exit(1) if base.find('/')==-1: files.append(base) return files