From 20f48d4535bab609f4c3876b79da054a73665226 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Mon, 1 Oct 2018 19:30:44 +0200 Subject: [PATCH] [module/datetime] Add more error handling to locale setting If setting a locale fails with an exception, set to en_US.UTF-8 by default. fixes #159 --- bumblebee/modules/datetime.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bumblebee/modules/datetime.py b/bumblebee/modules/datetime.py index ffd0b0d..14c2d67 100644 --- a/bumblebee/modules/datetime.py +++ b/bumblebee/modules/datetime.py @@ -35,7 +35,10 @@ class Module(bumblebee.engine.Module): if not l or l == (None, None): l = ('en_US', 'UTF-8') lcl = self.parameter("locale", ".".join(l)) - locale.setlocale(locale.LC_TIME, lcl.split(".")) + try: + locale.setlocale(locale.LC_TIME, lcl.split(".")) + except Exception as e: + locale.setlocale(locale.LC_TIME, lcl.split("en_US.UTF-8")) def get_time(self, widget): enc = locale.getpreferredencoding()