(Python): Use more modern `raise' syntax.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 27 May 2018 14:59:13 +0000 (15:59 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 14 Jun 2018 11:50:37 +0000 (12:50 +0100)
keys/tripe-keys.in
mon/tripemon.in
peerdb/tripe-newpeers.in
py/rmcr.py
py/tripe.py.in
svc/conntrack.in

index 593f142..4ec89e9 100644 (file)
@@ -166,7 +166,7 @@ def run(args):
   SYS.stdout.flush()
   rc = OS.spawnvp(OS.P_WAIT, args[0], args)
   if rc != 0:
-    raise SubprocessError, rc
+    raise SubprocessError(rc)
 
 def hexhyphens(bytes):
   """
@@ -217,7 +217,7 @@ def conf_read(f):
     if line[-1] == '\n': line = line[:-1]
     match = rx_keyval.match(line)
     if not match:
-      raise ConfigFileError, "%s:%d: bad line `%s'" % (f, lno, line)
+      raise ConfigFileError("%s:%d: bad line `%s'" % (f, lno, line))
     k, v = match.groups()
     conf[k] = conf_subst(v)
 
@@ -489,7 +489,7 @@ def cmd_update(args):
     ## Verify the signature
     want = C.bytes(rx_nonalpha.sub('', conf['hk-master']))
     got = fingerprint('repos/master.pub', 'master-%d' % seq)
-    if want != got: raise VerifyError
+    if want != got: raise VerifyError()
     run('''catsign -krepos/master.pub verify -avC -kmaster-%d
       -t${sig-fresh} tripe-keys.sig tripe-keys.tar.gz''' % seq)
 
index 7f48bd2..2470934 100644 (file)
@@ -40,7 +40,7 @@ import re as RX
 from cStringIO import StringIO
 
 try:
-  if OS.getenv('TRIPEMON_FORCE_GI'): raise ImportError
+  if OS.getenv('TRIPEMON_FORCE_GI'): raise ImportError()
   import pygtk
   pygtk.require('2.0')
   import gtk as G
@@ -773,7 +773,7 @@ class ValidatingEntry (G.Entry):
     ValidationError.
     """
     if not me.validp:
-      raise ValidationError
+      raise ValidationError()
     return G.Entry.get_text(me)
 
 def numericvalidate(min = None, max = None):
index 700e69d..f123255 100644 (file)
@@ -92,7 +92,7 @@ class BulkResolver (object):
     """
     addr = me._namemap[host]
     if addr is None:
-      raise KeyError, host
+      raise KeyError(host)
     return addr
 
   def _resolved(me, host, addr):
@@ -236,7 +236,7 @@ class MyConfigParser (CP.RawConfigParser):
       pass
     else:
       if threadp:
-        raise InheritanceCycleError(key, path)
+        raise InheritanceCycleError(key, path)
 
     ## See whether the answer is ready waiting for us.
     try:
@@ -272,7 +272,7 @@ class MyConfigParser (CP.RawConfigParser):
         value = v
         winner = pp
       elif value != v:
-        raise AmbiguousOptionError(key, winner, value, pp, v)
+        raise AmbiguousOptionError(key, winner, value, pp, v)
 
     ## That's the best we could manage.
     path.pop()
@@ -291,7 +291,7 @@ class MyConfigParser (CP.RawConfigParser):
     else:
       value, _ = me._get(sec, key)
       if value is None:
-        raise MissingKeyException(sec, key)
+        raise MissingKeyException(sec, key)
 
     ## Expand the value and return it.
     return me._expand(sec, value, resolvep)
index e2c0325..6c846cb 100644 (file)
@@ -50,7 +50,7 @@ def _switchto(cr, arg = None, exc = None):
   global active
   _debug('> _switchto(%s, %s, %s)' % (cr, arg, exc))
   if not cr.livep:
-    raise ValueError, 'coroutine is dead'
+    raise ValueError('coroutine is dead')
   cr._arg = arg
   cr._exc = exc
   if cr is active:
index be24cc8..5562d7b 100644 (file)
@@ -109,7 +109,7 @@ import os as OS
 
 try:
   if OS.getenv('TRIPE_FORCE_RMCR') is not None:
-    raise ImportError
+    raise ImportError()
   from py.magic import greenlet as _Coroutine
 except ImportError:
   from rmcr import Coroutine as _Coroutine
@@ -508,7 +508,7 @@ class TripeCommandIterator (object):
     """
     me.dcr = Coroutine.getcurrent().parent
     if me.dcr is None:
-      raise ValueError, 'must invoke from coroutine'
+      raise ValueError('must invoke from coroutine')
     me.filter = filter or (lambda x: x)
     if bg:
       words = [words[0], '-background', dispatcher.bgtag()] + list(words[1:])
@@ -532,17 +532,17 @@ class TripeCommandIterator (object):
     if code == 'INFO':
       return me.filter(rest)
     elif code == 'OK':
-      raise StopIteration
+      raise StopIteration()
     elif code == 'CONNERR':
       if rest is None:
-        raise TripeConnectionError, 'connection terminated by user'
+        raise TripeConnectionError('connection terminated by user')
       else:
         raise rest
     elif code == 'FAIL':
       raise TripeError(*rest)
     else:
-      raise TripeInternalError \
-            ('unexpected tripe response %r' % ([code] + rest))
+      raise TripeInternalError('unexpected tripe response %r' %
+                               ([code] + rest))
 
 ### Simple utility functions for the TripeCommandIterator convenience
 ### methods.
@@ -1172,7 +1172,7 @@ class TripeServiceCommand (object):
     """
     if (me.min is not None and len(args) < me.min) or \
        (me.max is not None and len(args) > me.max):
-      raise TripeSyntaxError
+      raise TripeSyntaxError()
     me.func(*args)
 
 class TripeServiceJob (Coroutine):
@@ -1383,12 +1383,12 @@ class OptParse (object):
     if len(me.args) == 0 or \
        len(me.args[0]) < 2 or \
        not me.args[0].startswith('-'):
-      raise StopIteration
+      raise StopIteration()
     opt = me.args.pop(0)
     if opt == '--':
-      raise StopIteration
+      raise StopIteration()
     if opt not in me.allowed:
-      raise TripeSyntaxError
+      raise TripeSyntaxError()
     return opt
 
   def arg(me):
@@ -1398,7 +1398,7 @@ class OptParse (object):
     If none is available, raise `TripeSyntaxError'.
     """
     if len(me.args) == 0:
-      raise TripeSyntaxError
+      raise TripeSyntaxError()
     return me.args.pop(0)
 
   def rest(me, min = None, max = None):
@@ -1410,7 +1410,7 @@ class OptParse (object):
     """
     if (min is not None and len(me.args) < min) or \
        (max is not None and len(me.args) > max):
-      raise TripeSyntaxError
+      raise TripeSyntaxError()
     return me.args
 
 ###----- That's all, folks --------------------------------------------------
index 7379303..3368295 100644 (file)
@@ -211,7 +211,7 @@ def cmd_showgroup(g):
       pats = p
       break
   else:
-    raise T.TripeJobError, 'unknown-group', g
+    raise T.TripeJobError('unknown-group', g)
   for t, p, a, m in pats:
     T.svcinfo('peer', t,
               'target', p or '(default)',