From 1a5ad3b6f7ee0f54e0eb58e5766f792310596669 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sat, 9 Mar 2013 22:38:05 +0000 Subject: [PATCH] [r21597]Grampslocale: Protect from crashes due to passing bad strings to setlocale svn: r21600 --- gramps/gen/utils/grampslocale.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gramps/gen/utils/grampslocale.py b/gramps/gen/utils/grampslocale.py index d65f4aa02..0fc23f438 100644 --- a/gramps/gen/utils/grampslocale.py +++ b/gramps/gen/utils/grampslocale.py @@ -212,9 +212,12 @@ class GrampsLocale(object): #numeric format. Those are fixed by the user's system settings. if not win(): - locale.setlocale(locale.LC_COLLATE, self.collation) - locale.setlocale(locale.LC_TIME, self.calendar) - locale.setlocale(locale.LC_MONETARY, self.currency) + try: + locale.setlocale(locale.LC_COLLATE, self.collation) + locale.setlocale(locale.LC_TIME, self.calendar) + locale.setlocale(locale.LC_MONETARY, self.currency) + except locale.Error: + pass #Next, we need to know what is the encoding from the native environment: self.encoding = locale.getlocale()[1] #GtkBuilder depends on reading Glade files as UTF-8 and crashes if it