summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2008-09-13 01:57:25 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2008-09-13 01:57:25 (GMT)
commitd9a9c1066c64900a902f5a70b132880e29749ecc (patch)
tree3a019489694ff69f0a94003e0eea5952020aeb6c
parent0bef15846fb3a3a0c2c277ee7bc22ace719a47b6 (diff)
downloadcpython-d9a9c1066c64900a902f5a70b132880e29749ecc.zip
cpython-d9a9c1066c64900a902f5a70b132880e29749ecc.tar.gz
cpython-d9a9c1066c64900a902f5a70b132880e29749ecc.tar.bz2
Update uses of string exceptions
-rwxr-xr-xDemo/classes/bitvec.py2
-rw-r--r--Demo/rpc/rpc.py6
-rwxr-xr-xDemo/scripts/fact.py4
-rw-r--r--Demo/threads/Coroutine.py4
4 files changed, 7 insertions, 9 deletions
diff --git a/Demo/classes/bitvec.py b/Demo/classes/bitvec.py
index 495a837..c0eafa0 100755
--- a/Demo/classes/bitvec.py
+++ b/Demo/classes/bitvec.py
@@ -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:
diff --git a/Demo/rpc/rpc.py b/Demo/rpc/rpc.py
index 0a14bf2..08ef2fb 100644
--- a/Demo/rpc/rpc.py
+++ b/Demo/rpc/rpc.py
@@ -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):
diff --git a/Demo/scripts/fact.py b/Demo/scripts/fact.py
index 6dafa66..c030187 100755
--- a/Demo/scripts/fact.py
+++ b/Demo/scripts/fact.py
@@ -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
diff --git a/Demo/threads/Coroutine.py b/Demo/threads/Coroutine.py
index 4cc65f7..5de2b62 100644
--- a/Demo/threads/Coroutine.py
+++ b/Demo/threads/Coroutine.py
@@ -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):