From 57caa135b4031d63bf861e2fd4393b6bde2a869b Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 17 Dec 2009 03:30:46 +0000 Subject: [PATCH] Convert bytes to unicode for exception messages. (trunk r15106) svn path=/main/branches/2.1.7/; revision=15107 --- pym/portage/_selinux.py | 8 ++++++++ 1 file changed, 8 insertions(+) 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) -- 2.26.2