From b5aa6154b350e110f3256100045502614c5141cb Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sat, 27 Jan 2007 23:08:08 +0000 Subject: [PATCH] * src/Utils.py: handle missing/invalid encoding * src/DisplayModels/_BaseModel.py: handle None vs. 0 svn: r7997 --- ChangeLog | 2 ++ configure.in | 2 +- src/DisplayModels/_BaseModel.py | 2 +- src/PageView.py | 3 ++- src/Utils.py | 20 ++++++++++++++------ 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9d5a12a38..995d93bc2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,6 @@ 2007-01-27 Don Allingham + * src/Utils.py: handle missing/invalid encoding + * src/DisplayModels/_BaseModel.py: handle None vs. 0 * src/Editors/_EditPerson.py (EditPerson._image_button_press): check for window already being open (#882) diff --git a/configure.in b/configure.in index 506a508f9..26a4e1a83 100644 --- a/configure.in +++ b/configure.in @@ -12,7 +12,7 @@ AC_CONFIG_MACRO_DIR([m4]) GNOME_DOC_INIT dnl RELEASE=0.SVN$(svnversion -n .) -RELEASE=0rc1 +RELEASE=1 VERSIONSTRING=$VERSION if test x"$RELEASE" != "x" diff --git a/src/DisplayModels/_BaseModel.py b/src/DisplayModels/_BaseModel.py index 50dd228b2..43fe4f974 100644 --- a/src/DisplayModels/_BaseModel.py +++ b/src/DisplayModels/_BaseModel.py @@ -162,7 +162,7 @@ class BaseModel(gtk.GenericTreeModel): i += 1 index = self.indexlist.get(handle) - if index: + if index != None: node = self.get_iter(index) self.row_inserted(index, node) diff --git a/src/PageView.py b/src/PageView.py index c1cc37695..df66a9ad7 100644 --- a/src/PageView.py +++ b/src/PageView.py @@ -298,7 +298,8 @@ class PersonNavView(BookMarkView): self.other_action = gtk.ActionGroup(self.title + '/PersonOther') self.other_action.add_actions([ - ('SetActive', gtk.STOCK_HOME, _("Set _Home Person"), None, None, self.set_default_person), + ('SetActive', gtk.STOCK_HOME, _("Set _Home Person"), None, + None, self.set_default_person), ]) self.add_action_group(self.back_action) diff --git a/src/Utils.py b/src/Utils.py index 51d52180c..3c18fb32b 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -110,9 +110,10 @@ def fix_encoding(value): try: return unicode(value) except: - codeset = locale.getpreferredencoding() - if codeset == 'UTF-8': - codeset = 'latin1' + try: + codeset = locale.getpreferredencoding() + except: + codeset = "UTF-8" return unicode(value,codeset) else: return value @@ -291,9 +292,16 @@ def find_file( filename): pass # Build list of alternate encodings - encodings = [sys.getfilesystemencoding(), locale.getpreferredencoding(), - 'UTF-8', 'ISO-8859-1'] - encodings = list(set(encodings)) + encodings = set() + + for enc in [sys.getfilesystemencoding, locale.getpreferredencoding]: + try: + encodings.add(enc) + except: + pass + encodings.add('UTF-8') + encodings.add('ISO-8859-1') + for enc in encodings: try: fname = filename.encode(enc)