Skip to content

Commit 7a4d3ac

Browse files
author
andrew.kuchling
committed
Update uses of string exceptions
git-svn-id: http://svn.python.org/projects/python/trunk@66432 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent b873710 commit 7a4d3ac

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

Demo/classes/bitvec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def _compute_len(param):
2121
mant, l = math.frexp(float(param))
2222
bitmask = 1L << l
2323
if bitmask <= param:
24-
raise 'FATAL', '(param, l) = %r' % ((param, l),)
24+
raise RuntimeError('(param, l) = %r' % ((param, l),))
2525
while l:
2626
bitmask = bitmask >> 1
2727
if param & bitmask:

Demo/rpc/rpc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ def pack_replyheader(self, xid, verf):
8080

8181

8282
# Exceptions
83-
BadRPCFormat = 'rpc.BadRPCFormat'
84-
BadRPCVersion = 'rpc.BadRPCVersion'
85-
GarbageArgs = 'rpc.GarbageArgs'
83+
class BadRPCFormat(Exception): pass
84+
class BadRPCVersion(Exception): pass
85+
class GarbageArgs(Exception): pass
8686

8787
class Unpacker(xdr.Unpacker):
8888

Demo/scripts/fact.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
import sys
99
from math import sqrt
1010

11-
error = 'fact.error' # exception
12-
1311
def fact(n):
14-
if n < 1: raise error # fact() argument should be >= 1
12+
if n < 1: raise ValueError # fact() argument should be >= 1
1513
if n == 1: return [] # special case
1614
res = []
1715
# Treat even factors special, so we can use i = i+2 later

Demo/threads/Coroutine.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ def wait(self):
9393
self.e.wait()
9494
self.e.clear()
9595

96-
Killed = 'Coroutine.Killed'
97-
EarlyExit = 'Coroutine.EarlyExit'
96+
class Killed(Exception): pass
97+
class EarlyExit(Exception): pass
9898

9999
class Coroutine:
100100
def __init__(self):

0 commit comments

Comments
 (0)