]> granicus.if.org Git - python/commitdiff
Update uses of string exceptions
authorAndrew M. Kuchling <amk@amk.ca>
Sat, 13 Sep 2008 01:57:25 +0000 (01:57 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Sat, 13 Sep 2008 01:57:25 +0000 (01:57 +0000)
Demo/classes/bitvec.py
Demo/rpc/rpc.py
Demo/scripts/fact.py
Demo/threads/Coroutine.py

index 495a83727a1842bbb3604762abb6d4db3f03b498..c0eafa0ddc03acc324ab10edf1d740c0b11ebde6 100755 (executable)
@@ -21,7 +21,7 @@ def _compute_len(param):
     mant, l = math.frexp(float(param))
     bitmask = 1L << l
     if bitmask <= param:
-        raise 'FATAL', '(param, l) = %r' % ((param, l),)
+        raise RuntimeError('(param, l) = %r' % ((param, l),))
     while l:
         bitmask = bitmask >> 1
         if param & bitmask:
index 0a14bf21308ec3cffb59855eeddb2e682dfdf3b5..08ef2fb5c667b7659b3181c2fd8a84f7cdd6c1b9 100644 (file)
@@ -80,9 +80,9 @@ class Packer(xdr.Packer):
 
 
 # Exceptions
-BadRPCFormat = 'rpc.BadRPCFormat'
-BadRPCVersion = 'rpc.BadRPCVersion'
-GarbageArgs = 'rpc.GarbageArgs'
+class BadRPCFormat(Exception): pass
+class BadRPCVersion(Exception): pass
+class GarbageArgs(Exception): pass
 
 class Unpacker(xdr.Unpacker):
 
index 6dafa66256f4aa419bb07c2f25afa9db44c27511..c030187e7b0ce90e6dbff4ad21ec40b6ea396bc8 100755 (executable)
@@ -8,10 +8,8 @@
 import sys
 from math import sqrt
 
-error = 'fact.error'            # exception
-
 def fact(n):
-    if n < 1: raise error   # fact() argument should be >= 1
+    if n < 1: raise ValueError # fact() argument should be >= 1
     if n == 1: return []    # special case
     res = []
     # Treat even factors special, so we can use i = i+2 later
index 4cc65f7bf8d1eafa82b78e98257e2a782916b7ab..5de2b62d1b49a9ba522dda7bffd4bb16652976f3 100644 (file)
@@ -93,8 +93,8 @@ class _CoEvent:
         self.e.wait()
         self.e.clear()
 
-Killed = 'Coroutine.Killed'
-EarlyExit = 'Coroutine.EarlyExit'
+class Killed(Exception): pass
+class EarlyExit(Exception): pass
 
 class Coroutine:
     def __init__(self):