[pypy-commit] pypy default: Test and fix. Also hopefully a translation fix.

arigo noreply at buildbot.pypy.org
Fri Jul 6 17:03:50 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r55945:d5a1bba9e6e5
Date: 2012-07-06 17:03 +0200
http://bitbucket.org/pypy/pypy/changeset/d5a1bba9e6e5/

Log:	Test and fix. Also hopefully a translation fix.

diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -9,7 +9,7 @@
 from pypy.objspace.std.multimethod import FailedToImplement
 from pypy.objspace.std.stdtypedef import SMM, StdTypeDef
 from pypy.objspace.std.register_all import register_all
-from pypy.rlib.rarithmetic import ovfcheck
+from pypy.rlib.rarithmetic import ovfcheck, widen
 from pypy.rlib.unroll import unrolling_iterable
 from pypy.rlib.objectmodel import specialize, keepalive_until_here
 from pypy.rpython.lltypesystem import lltype, rffi
@@ -518,7 +518,15 @@
             start = 0
         # <a performance hack>
         if oldlen == 1:
-            if self.buffer[0] == rffi.cast(mytype.itemtype, 0):
+            if self.unwrap == 'str_w' or self.unwrap == 'unicode_w':
+                zero = not ord(self.buffer[0])
+            elif self.unwrap == 'int_w' or self.unwrap == 'bigint_w':
+                zero = not widen(self.buffer[0])
+            #elif self.unwrap == 'float_w':
+            #    value = ...float(self.buffer[0])  xxx handle the case of -0.0
+            else:
+                zero = False
+            if zero:
                 a.setlen(newlen, zero=True, overallocate=False)
                 return a
             a.setlen(newlen, overallocate=False)
diff --git a/pypy/module/array/test/test_array.py b/pypy/module/array/test/test_array.py
--- a/pypy/module/array/test/test_array.py
+++ b/pypy/module/array/test/test_array.py
@@ -928,7 +928,15 @@
         assert b[22] == 0
         a *= 13
         assert a[22] == 0
-        assert len(a) == 26        
+        assert len(a) == 26
+        a = self.array('f', [-0.0])
+        b = a * 13
+        assert len(b) == 13
+        assert str(b[12]) == "-0.0"
+        a = self.array('d', [-0.0])
+        b = a * 13
+        assert len(b) == 13
+        assert str(b[12]) == "-0.0"
 
 
 class AppTestArrayBuiltinShortcut(AppTestArray):


More information about the pypy-commit mailing list