[pypy-commit] pypy default: Fix test (mostly, but I'm not sure I understand why it doesn't seem to

arigo pypy.commits at gmail.com
Sun Mar 5 02:45:01 EST 2017


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r90550:1a55bff39061
Date: 2017-03-05 08:44 +0100
http://bitbucket.org/pypy/pypy/changeset/1a55bff39061/

Log:	Fix test (mostly, but I'm not sure I understand why it doesn't seem
	to crash in a full pypy)

diff --git a/rpython/jit/metainterp/optimizeopt/info.py b/rpython/jit/metainterp/optimizeopt/info.py
--- a/rpython/jit/metainterp/optimizeopt/info.py
+++ b/rpython/jit/metainterp/optimizeopt/info.py
@@ -773,24 +773,33 @@
         from rpython.jit.metainterp.optimizeopt.intutils import ConstIntBound,\
                 IntLowerBound
 
-        if mode is None:
+        length = self.getstrlen1(mode)
+        if length < 0:
             # XXX we can do better if we know it's an array
             return IntLowerBound(0)
-        else:
-            return ConstIntBound(self.getstrlen1(mode))
+        return ConstIntBound(length)
 
     def getstrlen(self, op, string_optimizer, mode):
-        return ConstInt(self.getstrlen1(mode))
+        length = self.getstrlen1(mode)
+        if length < 0:
+            return None
+        return ConstInt(length)
 
     def getstrlen1(self, mode):
         from rpython.jit.metainterp.optimizeopt import vstring
-        
+
         if mode is vstring.mode_string:
             s = self._unpack_str(vstring.mode_string)
+            if s is None:
+                return -1
+            return len(s)
+        elif mode is vstring.mode_unicode:
+            s = self._unpack_str(vstring.mode_unicode)            
+            if s is None:
+                return -1
             return len(s)
         else:
-            s = self._unpack_str(vstring.mode_unicode)            
-            return len(s)
+            return -1
 
     def getstrhash(self, op, mode):
         from rpython.jit.metainterp.optimizeopt import vstring


More information about the pypy-commit mailing list