From: Zac Medico Date: Fri, 29 Jan 2010 18:45:33 +0000 (-0000) Subject: Rearrange _selinux ImportError handling so the workaround for bug #298310 X-Git-Tag: v2.1.7.17~37 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=767ec2aecdd77b4abc035f999317c601d68b1844;p=portage.git Rearrange _selinux ImportError handling so the workaround for bug #298310 isn't necessary. (trunk r15167) svn path=/main/branches/2.1.7/; revision=15235 --- diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 7e148a354..d9a82bc83 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -288,23 +288,19 @@ import shutil as _shutil shutil = _unicode_module_wrapper(_shutil, encoding=_encodings['fs']) # Imports below this point rely on the above unicode wrapper definitions. -_selinux = None -selinux = None -_selinux_merge = None try: import portage._selinux - # Make sure the _selinux attribute is correctly reinitialized after - # reload(portage) is called. See bug #298310. - _selinux = sys.modules['portage._selinux'] selinux = _unicode_module_wrapper(_selinux, encoding=_encodings['fs']) _selinux_merge = _unicode_module_wrapper(_selinux, encoding=_encodings['merge']) -except OSError as e: - sys.stderr.write("!!! SELinux not loaded: %s\n" % str(e)) +except (ImportError, OSError) as e: + if isinstance(e, OSError): + sys.stderr.write("!!! SELinux not loaded: %s\n" % str(e)) del e -except ImportError: - pass + _selinux = None + selinux = None + _selinux_merge = None from portage.manifest import Manifest