The earlier patch was half right. This also fixes bz#1007083.
Sometimes the array of character values uses signed bytes. --- pyanaconda/keyboard.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pyanaconda/keyboard.py b/pyanaconda/keyboard.py index 5b1643c..ee876a0 100644 --- a/pyanaconda/keyboard.py +++ b/pyanaconda/keyboard.py @@ -36,6 +36,7 @@ import types import os import re import shutil +import ctypes
from pyanaconda import iutil from pyanaconda import flags @@ -333,7 +334,7 @@ def item_str(s): elif type(s) == types.ListType: # XXX: this is the wrong case that should be fixed (rhbz#920595) i = s.index(0) - s = "".join(chr(char) for char in s[:i] if char in xrange(256)) + s = "".join(chr(ctypes.c_uint8(char).value) for char in s[:i])
return s.decode("utf-8") #there are some non-ascii layout descriptions
On 09/12/2013 12:01 PM, David Shea wrote:
Sometimes the array of character values uses signed bytes.
pyanaconda/keyboard.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pyanaconda/keyboard.py b/pyanaconda/keyboard.py index 5b1643c..ee876a0 100644 --- a/pyanaconda/keyboard.py +++ b/pyanaconda/keyboard.py @@ -36,6 +36,7 @@ import types import os import re import shutil +import ctypes
from pyanaconda import iutil from pyanaconda import flags @@ -333,7 +334,7 @@ def item_str(s): elif type(s) == types.ListType: # XXX: this is the wrong case that should be fixed (rhbz#920595) i = s.index(0)
s = "".join(chr(char) for char in s[:i] if char in xrange(256))
s = "".join(chr(ctypes.c_uint8(char).value) for char in s[:i]) return s.decode("utf-8") #there are some non-ascii layout descriptions
We might be able to remove that whole block soon. Libxklavier claims that they fixed the string types in 5.4.
On Thu, 2013-09-12 at 15:57 -0400, David Shea wrote:
On 09/12/2013 12:01 PM, David Shea wrote:
Sometimes the array of character values uses signed bytes.
pyanaconda/keyboard.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pyanaconda/keyboard.py b/pyanaconda/keyboard.py index 5b1643c..ee876a0 100644 --- a/pyanaconda/keyboard.py +++ b/pyanaconda/keyboard.py @@ -36,6 +36,7 @@ import types import os import re import shutil +import ctypes
from pyanaconda import iutil from pyanaconda import flags @@ -333,7 +334,7 @@ def item_str(s): elif type(s) == types.ListType: # XXX: this is the wrong case that should be fixed (rhbz#920595) i = s.index(0)
s = "".join(chr(char) for char in s[:i] if char in xrange(256))
s = "".join(chr(ctypes.c_uint8(char).value) for char in s[:i]) return s.decode("utf-8") #there are some non-ascii layout descriptionsWe might be able to remove that whole block soon. Libxklavier claims that they fixed the string types in 5.4.
Yeah, I've been waiting for it for quite a while now. By the way, it's more a bug in gobject-introspection than a bug in libxklavier [1].
[1] https://bugzilla.redhat.com/show_bug.cgi?id=920595
--- pyanaconda/keyboard.py | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/pyanaconda/keyboard.py b/pyanaconda/keyboard.py index ee876a0..fa10579 100644 --- a/pyanaconda/keyboard.py +++ b/pyanaconda/keyboard.py @@ -372,11 +372,17 @@ class XklWrapper(object): """
_instance = None + _instance_lang = None
@staticmethod def get_instance(): + # If the language has changed, we need to grab new strings + if os.environ["LANG"] != XklWrapper._instance_lang: + XklWrapper._instance = None + if not XklWrapper._instance: XklWrapper._instance = XklWrapper() + XklWrapper._instance_lang = os.environ["LANG"]
return XklWrapper._instance
On Thu, 2013-09-12 at 12:01 -0400, David Shea wrote:
The earlier patch was half right. This also fixes bz#1007083.
These both look good to me, thanks for taking care of it! I'll just look at it a bit further to find out if we could translate strings on the fly instead of creating another instance of the XklWrapper as that is quite an expensive action.
anaconda-patches@lists.fedorahosted.org