From 4fed6bdf7360b3f9d3ea4832973c398aa387f0a8 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 26 Aug 2010 14:49:34 -0700 Subject: Ensure SystemExit is never caught. --- pym/_emerge/depgraph.py | 4 ++-- pym/portage/cache/sql_template.py | 4 ++++ pym/portage/dispatch_conf.py | 4 ++-- pym/portage/getbinpkg.py | 2 +- pym/portage/locks.py | 2 ++ pym/portage/process.py | 2 ++ pym/portage/tests/__init__.py | 4 ++++ 7 files changed, 17 insertions(+), 5 deletions(-) (limited to 'pym') diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index 4517f28b6..effb2e541 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -3197,9 +3197,9 @@ class depgraph(object): success, atoms = portage.dep_check(depstr, final_db, pkgsettings, myuse=self._pkg_use_enabled(pkg), trees=self._dynamic_config._graph_trees, myroot=myroot) + except SystemExit: + raise except Exception as e: - if isinstance(e, SystemExit): - raise # This is helpful, for example, if a ValueError # is thrown from cpv_expand due to multiple # matches (this can happen if an atom lacks a diff --git a/pym/portage/cache/sql_template.py b/pym/portage/cache/sql_template.py index d3c6a0b30..d023b1b5d 100644 --- a/pym/portage/cache/sql_template.py +++ b/pym/portage/cache/sql_template.py @@ -129,6 +129,8 @@ class SQLDatabase(template.database): raise cache_errors.CacheCorruption(self, cpv, e) if self.con.rowcount <= 0: raise KeyError(cpv) + except SystemExit: + raise except Exception: if not self.autocommits: self.db.rollback() @@ -166,6 +168,8 @@ class SQLDatabase(template.database): if self.autocommits: self.commit() + except SystemExit: + raise except Exception: if not self.autocommits: try: diff --git a/pym/portage/dispatch_conf.py b/pym/portage/dispatch_conf.py index b4cded266..c543afd33 100644 --- a/pym/portage/dispatch_conf.py +++ b/pym/portage/dispatch_conf.py @@ -79,7 +79,7 @@ def rcs_archive(archive, curconf, newconf, mrgconf): try: os.makedirs(os.path.dirname(archive)) - except: + except OSError: pass try: @@ -125,7 +125,7 @@ def file_archive(archive, curconf, newconf, mrgconf): try: os.makedirs(os.path.dirname(archive)) - except: + except OSError: pass # Archive the current config file if it isn't already saved diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py index e15853f1e..56167c504 100644 --- a/pym/portage/getbinpkg.py +++ b/pym/portage/getbinpkg.py @@ -23,7 +23,7 @@ except ImportError: try: from urllib.parse import unquote as urllib_parse_unquote -except: +except ImportError: from urllib2 import unquote as urllib_parse_unquote try: diff --git a/pym/portage/locks.py b/pym/portage/locks.py index 4a86e5acb..000e4fac0 100644 --- a/pym/portage/locks.py +++ b/pym/portage/locks.py @@ -236,6 +236,8 @@ def unlockfile(mytuple): writemsg(_("lockfile does not exist '%s'\n") % lockfilename, 1) os.close(myfd) return False + except SystemExit: + raise except Exception as e: writemsg(_("Failed to get lock... someone took it.\n"), 1) writemsg(str(e)+"\n",1) diff --git a/pym/portage/process.py b/pym/portage/process.py index aed727167..66ec1edd0 100644 --- a/pym/portage/process.py +++ b/pym/portage/process.py @@ -246,6 +246,8 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False, try: _exec(binary, mycommand, opt_name, fd_pipes, env, gid, groups, uid, umask, pre_exec) + except SystemExit: + raise except Exception as e: # We need to catch _any_ exception so that it doesn't # propogate out of this function and cause exiting diff --git a/pym/portage/tests/__init__.py b/pym/portage/tests/__init__.py index bd41f1ee8..3c3305252 100644 --- a/pym/portage/tests/__init__.py +++ b/pym/portage/tests/__init__.py @@ -153,6 +153,8 @@ class TestCase(unittest.TestCase): try: try: self.setUp() + except SystemExit: + raise except KeyboardInterrupt: raise except: @@ -173,6 +175,8 @@ class TestCase(unittest.TestCase): result.addError(self, sys.exc_info()) try: self.tearDown() + except SystemExit: + raise except KeyboardInterrupt: raise except: -- cgit v1.2.3-1-g7c22