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

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

 



On 03/25/2010 03:51 PM, Ales Kozumplik wrote:
On 03/25/2010 02:43 PM, Chris Lumens wrote:
try:
ret = fn(*args, **kwds)
finally:
locale.setlocale(locale.LC_MESSAGES, oldlocale)

return ret

That *should* work in all cases just like what you've got above and
involves less exception manipulation.

Nice, I was looking for a construct to do exactly this.


You're not in the gitpyparted group so if you want to move this (and the
RHEL6 bug) to pyparted and attach a patch, either David or I will commit
it for you.

Absolutely, please commit---the patch is attached, bug for rhel6 is
576848, for Fedora it is 571940.

Thanks.
Ales

Fixed patch.

Ales
>From 69cc595445fafcf2fd6e5f54b86ee7145e99eb9a Mon Sep 17 00:00:00 2001
From: Ales Kozumplik <akozumpl@xxxxxxxxxx>
Date: Thu, 25 Mar 2010 11:26:25 +0100
Subject: [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, 4 insertions(+), 2 deletions(-)

diff --git a/src/parted/decorators.py b/src/parted/decorators.py
index 2f72dd9..7264c0e 100644
--- a/src/parted/decorators.py
+++ b/src/parted/decorators.py
@@ -27,8 +27,10 @@ import locale
 def localeC(fn, *args, **kwds):
     oldlocale = locale.getlocale(locale.LC_MESSAGES)
     locale.setlocale(locale.LC_MESSAGES, 'C')
-    ret = fn(*args, **kwds)
-    locale.setlocale(locale.LC_MESSAGES, oldlocale)
+    try:
+        ret = fn(*args, **kwds)
+    finally:
+        locale.setlocale(locale.LC_MESSAGES, oldlocale)
     return ret
 
 
-- 
1.6.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux