From 4fad9366c0269b4a836931475c986a01c91b09b0 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 17 Dec 2009 03:30:22 +0000 Subject: Convert bytes to unicode for exception messages. svn path=/main/trunk/; revision=15106 --- pym/portage/_selinux.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'pym/portage/_selinux.py') diff --git a/pym/portage/_selinux.py b/pym/portage/_selinux.py index 5367afc9c..e6d44b70b 100644 --- a/pym/portage/_selinux.py +++ b/pym/portage/_selinux.py @@ -21,6 +21,7 @@ def copyfile(src, dest): dest = _unicode_encode(dest, encoding=_encodings['fs'], errors='strict') (rc, ctx) = selinux.lgetfilecon(src) if rc < 0: + src = _unicode_decode(src, encoding=_encodings['fs'], errors='replace') raise OSError(_("copyfile: Failed getting context of \"%s\".") % src) setfscreate(ctx) @@ -41,6 +42,8 @@ def mkdir(target, refdir): refdir = _unicode_encode(refdir, encoding=_encodings['fs'], errors='strict') (rc, ctx) = selinux.getfilecon(refdir) if rc < 0: + refdir = _unicode_decode(refdir, encoding=_encodings['fs'], + errors='replace') raise OSError( _("mkdir: Failed getting context of reference directory \"%s\".") \ % refdir) @@ -56,6 +59,7 @@ def rename(src, dest): dest = _unicode_encode(dest, encoding=_encodings['fs'], errors='strict') (rc, ctx) = selinux.lgetfilecon(src) if rc < 0: + src = _unicode_decode(src, encoding=_encodings['fs'], errors='replace') raise OSError(_("rename: Failed getting context of \"%s\".") % src) setfscreate(ctx) @@ -85,6 +89,8 @@ def setfscreate(ctx="\n"): ctx = _unicode_encode(ctx, encoding=_encodings['content'], errors='strict') if selinux.setfscreatecon(ctx) < 0: + ctx = _unicode_decode(ctx, + encoding=_encodings['content'], errors='replace') raise OSError( _("setfscreate: Failed setting fs create context \"%s\".") % ctx) @@ -109,6 +115,8 @@ def symlink(target, link, reflnk): reflnk = _unicode_encode(reflnk, encoding=_encodings['fs'], errors='strict') (rc, ctx) = selinux.lgetfilecon(reflnk) if rc < 0: + reflnk = _unicode_decode(reflnk, encoding=_encodings['fs'], + errors='replace') raise OSError( _("symlink: Failed getting context of reference symlink \"%s\".") \ % reflnk) -- cgit v1.2.3-1-g7c22