[pypy-commit] pypy default: better error messages for newlist_hint() and resizelist_hint()

rlamy noreply at buildbot.pypy.org
Tue Feb 4 02:04:01 CET 2014


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: 
Changeset: r69068:372d7cd3d6b7
Date: 2014-02-04 01:03 +0000
http://bitbucket.org/pypy/pypy/changeset/372d7cd3d6b7/

Log:	better error messages for newlist_hint() and resizelist_hint()

diff --git a/rpython/rlib/objectmodel.py b/rpython/rlib/objectmodel.py
--- a/rpython/rlib/objectmodel.py
+++ b/rpython/rlib/objectmodel.py
@@ -338,9 +338,10 @@
     _about_ = newlist_hint
 
     def compute_result_annotation(self, s_sizehint):
-        from rpython.annotator.model import SomeInteger
+        from rpython.annotator.model import SomeInteger, AnnotatorError
 
-        assert isinstance(s_sizehint, SomeInteger)
+        if not isinstance(s_sizehint, SomeInteger):
+            raise AnnotatorError("newlist_hint() argument must be an int")
         s_l = self.bookkeeper.newlist()
         s_l.listdef.listitem.resize()
         return s_l
@@ -365,8 +366,10 @@
 
     def compute_result_annotation(self, s_l, s_sizehint):
         from rpython.annotator import model as annmodel
-        assert isinstance(s_l, annmodel.SomeList)
-        assert isinstance(s_sizehint, annmodel.SomeInteger)
+        if not isinstance(s_l, annmodel.SomeList):
+            raise annmodel.AnnotatorError("First argument must be a list")
+        if not isinstance(s_sizehint, annmodel.SomeInteger):
+            raise annmodel.AnnotatorError("Second argument must be an integer")
         s_l.listdef.listitem.resize()
 
     def specialize_call(self, hop):


More information about the pypy-commit mailing list