[Python-checkins] r66432 - in python/trunk/Demo: classes/bitvec.py rpc/rpc.py scripts/fact.py threads/Coroutine.py
andrew.kuchling
python-checkins at python.org
Sat Sep 13 03:57:26 CEST 2008
Author: andrew.kuchling
Date: Sat Sep 13 03:57:25 2008
New Revision: 66432
Log:
Update uses of string exceptions
Modified:
python/trunk/Demo/classes/bitvec.py
python/trunk/Demo/rpc/rpc.py
python/trunk/Demo/scripts/fact.py
python/trunk/Demo/threads/Coroutine.py
Modified: python/trunk/Demo/classes/bitvec.py
==============================================================================
--- python/trunk/Demo/classes/bitvec.py (original)
+++ python/trunk/Demo/classes/bitvec.py Sat Sep 13 03:57:25 2008
@@ -21,7 +21,7 @@
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:
Modified: python/trunk/Demo/rpc/rpc.py
==============================================================================
--- python/trunk/Demo/rpc/rpc.py (original)
+++ python/trunk/Demo/rpc/rpc.py Sat Sep 13 03:57:25 2008
@@ -80,9 +80,9 @@
# 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):
Modified: python/trunk/Demo/scripts/fact.py
==============================================================================
--- python/trunk/Demo/scripts/fact.py (original)
+++ python/trunk/Demo/scripts/fact.py Sat Sep 13 03:57:25 2008
@@ -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
Modified: python/trunk/Demo/threads/Coroutine.py
==============================================================================
--- python/trunk/Demo/threads/Coroutine.py (original)
+++ python/trunk/Demo/threads/Coroutine.py Sat Sep 13 03:57:25 2008
@@ -93,8 +93,8 @@
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):
More information about the Python-checkins
mailing list