From 72165c7717e26050c6785f8b103f69baaa06dd40 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 15 Oct 2009 15:14:59 -0400 Subject: [PATCH] Convert all usage of two-expression exception raising to modern syntax Replace all usage of the two-expression raise foo, 'bar' syntax with the long-equivalent raise foo('bar') as the old syntax was removed in Python 3 (PEP 3109), and the new syntax is supported in Python 2 --- python/rpm/transaction.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/python/rpm/transaction.py b/python/rpm/transaction.py index 8c7fb1f..8e9ab59 100644 --- a/python/rpm/transaction.py +++ b/python/rpm/transaction.py @@ -57,11 +57,11 @@ class TransactionSet(_rpmts): header = item if not how in ['u', 'i']: - raise ValueError, 'how argument must be "u" or "i"' + raise ValueError('how argument must be "u" or "i"') upgrade = (how == "u") if not _rpmts.addInstall(self, header, key, upgrade): - raise rpm.error, "adding package to transaction failed" + raise rpm.error("adding package to transaction failed") self._keyList.append(key) def addErase(self, item): @@ -75,11 +75,11 @@ class TransactionSet(_rpmts): elif isinstance(item, str): hdrs = self.dbMatch(rpm.RPMDBI_LABEL, item) else: - raise TypeError, "invalid type %s" % type(item) + raise TypeError("invalid type %s" % type(item)) for h in hdrs: if not _rpmts.addErase(self, h): - raise rpm.error, "package not installed" + raise rpm.error("package not installed") # garbage collection should take care but just in case... if isinstance(hdrs, rpm.mi): @@ -144,20 +144,20 @@ class TransactionSet(_rpmts): res, msg = _rpmts.hdrCheck(self, blob) # generate backwards compatibly broken exceptions if res == rpm.RPMRC_NOKEY: - raise rpm.error, "public key not availaiable" + raise rpm.error("public key not availaiable") elif res == rpm.RPMRC_NOTTRUSTED: - raise rpm.error, "public key not trusted" + raise rpm.error("public key not trusted") elif res != rpm.RPMRC_OK: - raise rpm.error, msg + raise rpm.error(msg) def hdrFromFdno(self, fd): res, h = _rpmts.hdrFromFdno(self, fd) # generate backwards compatibly broken exceptions if res == rpm.RPMRC_NOKEY: - raise rpm.error, "public key not availaiable" + raise rpm.error("public key not availaiable") elif res == rpm.RPMRC_NOTTRUSTED: - raise rpm.error, "public key not trusted" + raise rpm.error("public key not trusted") elif res != rpm.RPMRC_OK: - raise rpm.error, "error reading package header" + raise rpm.error("error reading package header") return h -- 2.7.4