[kupfer: 34/38] Encode commandline in locale encoding in utils.spawn_async
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer: 34/38] Encode commandline in locale encoding in utils.spawn_async
- Date: Sat, 16 Jan 2010 17:14:39 +0000 (UTC)
commit 389d8efd4da8f652e615a8eb7fa3d7dabcf970ef
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Sat Jan 16 16:41:49 2010 +0100
Encode commandline in locale encoding in utils.spawn_async
kupfer/kupferstring.py | 5 +++++
kupfer/utils.py | 3 +++
2 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/kupferstring.py b/kupfer/kupferstring.py
index 66a6c64..31c3e16 100644
--- a/kupfer/kupferstring.py
+++ b/kupfer/kupferstring.py
@@ -47,6 +47,11 @@ def fromlocale(lstr):
enc = locale.getpreferredencoding(do_setlocale=False)
return lstr.decode(enc, "replace")
+def tolocale(ustr):
+ """Return a locale-encoded bytestring from unicode @ustr"""
+ enc = locale.getpreferredencoding(do_setlocale=False)
+ return ustr.encode(enc, "replace")
+
def tofolded(ustr):
u"""Fold @ustr
diff --git a/kupfer/utils.py b/kupfer/utils.py
index d7ee445..634d02b 100644
--- a/kupfer/utils.py
+++ b/kupfer/utils.py
@@ -6,6 +6,7 @@ import locale
import gobject
from kupfer import pretty
+from kupfer import kupferstring
def get_dirlist(folder, depth=0, include=None, exclude=None):
"""
@@ -69,6 +70,8 @@ def locale_sort(seq, key=unicode):
def spawn_async(argv, in_dir="."):
pretty.print_debug(__name__, "Spawn commandline", argv, in_dir)
+ argv = [kupferstring.tolocale(A) if isinstance(A, unicode) else A
+ for A in argv]
try:
return gobject.spawn_async (argv, working_directory=in_dir,
flags=gobject.SPAWN_SEARCH_PATH)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]