diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-12-17 03:30:22 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-12-17 03:30:22 +0000 |
commit | 4fad9366c0269b4a836931475c986a01c91b09b0 (patch) | |
tree | c0b809b4f2cd88eeff3ce0757a8ad14db50f8a56 | |
parent | 802efcc73d0636964a76ae70ea96f2aaf9e5b089 (diff) | |
download | portage-4fad9366c0269b4a836931475c986a01c91b09b0.tar.gz portage-4fad9366c0269b4a836931475c986a01c91b09b0.tar.bz2 portage-4fad9366c0269b4a836931475c986a01c91b09b0.zip |
Convert bytes to unicode for exception messages.
svn path=/main/trunk/; revision=15106
-rw-r--r-- | pym/portage/_selinux.py | 8 |
1 files changed, 8 insertions, 0 deletions
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) |