Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 335564 Details for
Bug 430488
sys-apps/portage selinux code still requires python-2
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
portage.patch
portage.patch (text/plain), 5.93 KB, created by
Arfrever Frehtes Taifersar Arahesis
on 2013-01-14 07:23:10 UTC
(
hide
)
Description:
portage.patch
Filename:
MIME Type:
Creator:
Arfrever Frehtes Taifersar Arahesis
Created:
2013-01-14 07:23:10 UTC
Size:
5.93 KB
patch
obsolete
>diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py >index 169c197..6d7b101 100644 >--- a/pym/portage/__init__.py >+++ b/pym/portage/__init__.py >@@ -181,6 +181,8 @@ if sys.hexversion >= 0x3000000: > if isinstance(s, bytes): > s = str(s, encoding=encoding, errors=errors) > return s >+ >+ _native_string = _unicode_decode > else: > def _unicode_encode(s, encoding=_encodings['content'], errors='backslashreplace'): > if isinstance(s, unicode): >@@ -192,6 +194,8 @@ else: > s = unicode(s, encoding=encoding, errors=errors) > return s > >+ _native_string = _unicode_encode >+ > class _unicode_func_wrapper(object): > """ > Wraps a function, converts arguments from unicode to bytes, >diff --git a/pym/portage/_selinux.py b/pym/portage/_selinux.py >index 1737145..e4621b1 100644 >--- a/pym/portage/_selinux.py >+++ b/pym/portage/_selinux.py >@@ -1,4 +1,4 @@ >-# Copyright 1999-2011 Gentoo Foundation >+# Copyright 1999-2013 Gentoo Foundation > # Distributed under the terms of the GNU General Public License v2 > > # Don't use the unicode-wrapped os and shutil modules here since >@@ -8,18 +8,18 @@ import shutil > > import portage > from portage import _encodings >-from portage import _unicode_decode >-from portage import _unicode_encode >+from portage import _native_string, _unicode_decode > from portage.localization import _ > portage.proxy.lazyimport.lazyimport(globals(), > 'selinux') > > def copyfile(src, dest): >- src = _unicode_encode(src, encoding=_encodings['fs'], errors='strict') >- dest = _unicode_encode(dest, encoding=_encodings['fs'], errors='strict') >+ src = _native_string(src, encoding=_encodings['fs'], errors='strict') >+ dest = _native_string(dest, encoding=_encodings['fs'], errors='strict') > (rc, ctx) = selinux.lgetfilecon(src) > if rc < 0: >- src = _unicode_decode(src, encoding=_encodings['fs'], errors='replace') >+ if sys.hexversion < 0x3000000: >+ src = _unicode_decode(src, encoding=_encodings['fs'], errors='replace') > raise OSError(_("copyfile: Failed getting context of \"%s\".") % src) > > setfscreate(ctx) >@@ -39,12 +39,12 @@ def is_selinux_enabled(): > return selinux.is_selinux_enabled() > > def mkdir(target, refdir): >- target = _unicode_encode(target, encoding=_encodings['fs'], errors='strict') >- refdir = _unicode_encode(refdir, encoding=_encodings['fs'], errors='strict') >+ target = _native_string(target, encoding=_encodings['fs'], errors='strict') >+ refdir = _native_string(refdir, encoding=_encodings['fs'], errors='strict') > (rc, ctx) = selinux.getfilecon(refdir) > if rc < 0: >- refdir = _unicode_decode(refdir, encoding=_encodings['fs'], >- errors='replace') >+ if sys.hexversion < 0x3000000: >+ refdir = _unicode_decode(refdir, encoding=_encodings['fs'], errors='replace') > raise OSError( > _("mkdir: Failed getting context of reference directory \"%s\".") \ > % refdir) >@@ -56,11 +56,12 @@ def mkdir(target, refdir): > setfscreate() > > def rename(src, dest): >- src = _unicode_encode(src, encoding=_encodings['fs'], errors='strict') >- dest = _unicode_encode(dest, encoding=_encodings['fs'], errors='strict') >+ src = _native_string(src, encoding=_encodings['fs'], errors='strict') >+ dest = _native_string(dest, encoding=_encodings['fs'], errors='strict') > (rc, ctx) = selinux.lgetfilecon(src) > if rc < 0: >- src = _unicode_decode(src, encoding=_encodings['fs'], errors='replace') >+ if sys.hexversion < 0x3000000: >+ src = _unicode_decode(src, encoding=_encodings['fs'], errors='replace') > raise OSError(_("rename: Failed getting context of \"%s\".") % src) > > setfscreate(ctx) >@@ -75,10 +76,10 @@ def settype(newtype): > return ":".join(ret) > > def setexec(ctx="\n"): >- ctx = _unicode_encode(ctx, encoding=_encodings['content'], errors='strict') >+ ctx = _native_string(ctx, encoding=_encodings['content'], errors='strict') > if selinux.setexeccon(ctx) < 0: >- ctx = _unicode_decode(ctx, encoding=_encodings['content'], >- errors='replace') >+ if sys.hexversion < 0x3000000: >+ ctx = _unicode_decode(ctx, encoding=_encodings['content'], errors='replace') > if selinux.security_getenforce() == 1: > raise OSError(_("Failed setting exec() context \"%s\".") % ctx) > else: >@@ -87,11 +88,10 @@ def setexec(ctx="\n"): > noiselevel=-1) > > def setfscreate(ctx="\n"): >- ctx = _unicode_encode(ctx, >- encoding=_encodings['content'], errors='strict') >+ ctx = _native_string(ctx, encoding=_encodings['content'], errors='strict') > if selinux.setfscreatecon(ctx) < 0: >- ctx = _unicode_decode(ctx, >- encoding=_encodings['content'], errors='replace') >+ if sys.hexversion < 0x3000000: >+ ctx = _unicode_decode(ctx, encoding=_encodings['content'], errors='replace') > raise OSError( > _("setfscreate: Failed setting fs create context \"%s\".") % ctx) > >@@ -106,8 +106,7 @@ class spawn_wrapper(object): > > def __init__(self, spawn_func, selinux_type): > self._spawn_func = spawn_func >- selinux_type = _unicode_encode(selinux_type, >- encoding=_encodings['content'], errors='strict') >+ selinux_type = _native_string(selinux_type, encoding=_encodings['content'], errors='strict') > self._con = settype(selinux_type) > > def __call__(self, *args, **kwargs): >@@ -123,13 +122,13 @@ class spawn_wrapper(object): > return self._spawn_func(*args, **kwargs) > > def symlink(target, link, reflnk): >- target = _unicode_encode(target, encoding=_encodings['fs'], errors='strict') >- link = _unicode_encode(link, encoding=_encodings['fs'], errors='strict') >- reflnk = _unicode_encode(reflnk, encoding=_encodings['fs'], errors='strict') >+ target = _native_string(target, encoding=_encodings['fs'], errors='strict') >+ link = _native_string(link, encoding=_encodings['fs'], errors='strict') >+ reflnk = _native_string(reflnk, encoding=_encodings['fs'], errors='strict') > (rc, ctx) = selinux.lgetfilecon(reflnk) > if rc < 0: >- reflnk = _unicode_decode(reflnk, encoding=_encodings['fs'], >- errors='replace') >+ if sys.hexversion < 0x3000000: >+ reflnk = _unicode_decode(reflnk, encoding=_encodings['fs'], errors='replace') > raise OSError( > _("symlink: Failed getting context of reference symlink \"%s\".") \ > % reflnk)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 430488
: 335564