Author: Ronan Lamy <[email protected]>
Branch:
Changeset: r82075:b8933a584083
Date: 2016-02-04 16:46 +0000
http://bitbucket.org/pypy/pypy/changeset/b8933a584083/
Log: Use the correct exceptions in rpython/annotator/builtin.py
diff --git a/rpython/annotator/builtin.py b/rpython/annotator/builtin.py
--- a/rpython/annotator/builtin.py
+++ b/rpython/annotator/builtin.py
@@ -39,8 +39,9 @@
return s_result
s_realresult = immutablevalue(realresult)
if not s_result.contains(s_realresult):
- raise Exception("%s%r returned %r, which is not contained in %s" % (
- func, args, realresult, s_result))
+ raise AnnotatorError(
+ "%s%r returned %r, which is not contained in %s" % (
+ func, args, realresult, s_result))
return s_realresult
# ____________________________________________________________
@@ -56,14 +57,14 @@
s_start, s_stop = args[:2]
s_step = args[2]
else:
- raise Exception("range() takes 1 to 3 arguments")
+ raise AnnotatorError("range() takes 1 to 3 arguments")
empty = False # so far
if not s_step.is_constant():
step = 0 # this case signals a variable step
else:
step = s_step.const
if step == 0:
- raise Exception("range() with step zero")
+ raise AnnotatorError("range() with step zero")
if s_start.is_constant() and s_stop.is_constant():
try:
if len(xrange(s_start.const, s_stop.const, step)) == 0:
@@ -285,7 +286,8 @@
else:
@analyzer_for(unicodedata.decimal)
def unicodedata_decimal(s_uchr):
- raise TypeError("unicodedate.decimal() calls should not happen at
interp-level")
+ raise AnnotatorError(
+ "unicodedate.decimal() calls should not happen at interp-level")
@analyzer_for(OrderedDict)
def analyze():
@@ -299,9 +301,9 @@
@analyzer_for(weakref.ref)
def weakref_ref(s_obj):
if not isinstance(s_obj, SomeInstance):
- raise Exception("cannot take a weakref to %r" % (s_obj,))
+ raise AnnotatorError("cannot take a weakref to %r" % (s_obj,))
if s_obj.can_be_None:
- raise Exception("should assert that the instance we take "
+ raise AnnotatorError("should assert that the instance we take "
"a weakref to cannot be None")
return SomeWeakRef(s_obj.classdef)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit