[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[pyparted] Restore locales even when an exception is thrown (#571940).



Otherwise this disables translations of all glade strings in anaconda.
---
 src/parted/decorators.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/parted/decorators.py b/src/parted/decorators.py
index 2f72dd9..dce3f1d 100644
--- a/src/parted/decorators.py
+++ b/src/parted/decorators.py
@@ -27,7 +27,11 @@ import locale
 def localeC(fn, *args, **kwds):
     oldlocale = locale.getlocale(locale.LC_MESSAGES)
     locale.setlocale(locale.LC_MESSAGES, 'C')
-    ret = fn(*args, **kwds)
+    try:
+        ret = fn(*args, **kwds)
+    except Exception as e:
+        locale.setlocale(locale.LC_MESSAGES, oldlocale)
+        raise e
     locale.setlocale(locale.LC_MESSAGES, oldlocale)
     return ret
 
-- 
1.6.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]