[pypy-commit] pypy default: merged upstream

alex_gaynor noreply at buildbot.pypy.org
Fri Nov 11 17:25:49 CET 2011


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r49327:909a9ae3ef61
Date: 2011-11-11 11:25 -0500
http://bitbucket.org/pypy/pypy/changeset/909a9ae3ef61/

Log:	merged upstream

diff --git a/pypy/module/_rawffi/structure.py b/pypy/module/_rawffi/structure.py
--- a/pypy/module/_rawffi/structure.py
+++ b/pypy/module/_rawffi/structure.py
@@ -212,6 +212,8 @@
                 while count + basic_size <= total_size:
                     fieldtypes.append(basic_ffi_type)
                     count += basic_size
+                    if basic_size == 0: # corner case. get out of this infinite
+                        break           # loop after 1 iteration ("why not")
             self.ffi_struct = clibffi.make_struct_ffitype_e(self.size,
                                                            self.alignment,
                                                            fieldtypes)
diff --git a/pypy/rpython/lltypesystem/rffi.py b/pypy/rpython/lltypesystem/rffi.py
--- a/pypy/rpython/lltypesystem/rffi.py
+++ b/pypy/rpython/lltypesystem/rffi.py
@@ -862,11 +862,12 @@
     try:
         unsigned = not tp._type.SIGNED
     except AttributeError:
-        if tp in [lltype.Char, lltype.Float, lltype.Signed] or\
-               isinstance(tp, lltype.Ptr):
+        if (not isinstance(tp, lltype.Primitive) or
+            tp in (FLOAT, DOUBLE) or
+            cast(lltype.SignedLongLong, cast(tp, -1)) < 0):
             unsigned = False
         else:
-            unsigned = False
+            unsigned = True
     return size, unsigned
 
 def sizeof(tp):
diff --git a/pypy/translator/test/test_simplify.py b/pypy/translator/test/test_simplify.py
--- a/pypy/translator/test/test_simplify.py
+++ b/pypy/translator/test/test_simplify.py
@@ -42,24 +42,6 @@
     assert graph.startblock.operations[0].opname == 'int_mul_ovf'
     assert graph.startblock.operations[1].opname == 'int_sub'
 
-def test_remove_ovfcheck_lshift():
-    # check that ovfcheck_lshift() is handled
-    from pypy.rlib.rarithmetic import ovfcheck_lshift
-    def f(x):
-        try:
-            return ovfcheck_lshift(x, 2)
-        except OverflowError:
-            return -42
-    graph, _ = translate(f, [int])
-    assert len(graph.startblock.operations) == 1
-    assert graph.startblock.operations[0].opname == 'int_lshift_ovf'
-    assert len(graph.startblock.operations[0].args) == 2
-    assert len(graph.startblock.exits) == 2
-    assert [link.exitcase for link in graph.startblock.exits] == \
-           [None, OverflowError]
-    assert [link.target.operations for link in graph.startblock.exits] == \
-           [(), ()]
-
 def test_remove_ovfcheck_floordiv():
     # check that ovfcheck() is handled even if the operation raises
     # and catches another exception too, here ZeroDivisionError


More information about the pypy-commit mailing list