[pypy-svn] r34106 - pypy/dist/pypy/rpython/lltypesystem

arigo at codespeak.net arigo at codespeak.net
Fri Nov 3 15:01:39 CET 2006


Author: arigo
Date: Fri Nov  3 15:01:37 2006
New Revision: 34106

Modified:
   pypy/dist/pypy/rpython/lltypesystem/rstr.py
Log:
Assert that operations like slicing are not producing strings of
negative length.


Modified: pypy/dist/pypy/rpython/lltypesystem/rstr.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/rstr.py	(original)
+++ pypy/dist/pypy/rpython/lltypesystem/rstr.py	Fri Nov  3 15:01:37 2006
@@ -109,7 +109,10 @@
                                  resulttype=pyobj_repr,
                                  _callable= lambda chars, sz: pyobjectptr(''.join(chars)))
 
+from pypy.rpython.lltypesystem.lloperation import llop
+
 def mallocstr(length):
+    llop.debug_assert(Void, "%s >= 0 # negative string length", length)
     r = malloc(STR, length)
     if not we_are_translated() or not malloc_zero_filled:
         r.hash = 0
@@ -507,7 +510,6 @@
 
     def ll_stringslice_minusone(s1):
         newlen = len(s1.chars) - 1
-        assert newlen >= 0
         newstr = mallocstr(newlen)
         j = 0
         while j < newlen:



More information about the Pypy-commit mailing list