Author: Armin Rigo <ar...@tunes.org>
Branch: 
Changeset: r49465:914c5625808a
Date: 2011-11-16 12:37 +0100
http://bitbucket.org/pypy/pypy/changeset/914c5625808a/

Log:    Fix.

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,12 +862,14 @@
     try:
         unsigned = not tp._type.SIGNED
     except AttributeError:
-        if (not isinstance(tp, lltype.Primitive) or
-            tp in (FLOAT, DOUBLE) or
-            cast(lltype.SignedLongLong, cast(tp, -1)) < 0):
+        if not isinstance(tp, lltype.Primitive):
             unsigned = False
+        elif tp in (lltype.Signed, FLOAT, DOUBLE):
+            unsigned = False
+        elif tp in (lltype.Char, lltype.UniChar, lltype.Bool):
+            unsigned = True
         else:
-            unsigned = True
+            raise AssertionError("size_and_sign(%r)" % (tp,))
     return size, unsigned
 
 def sizeof(tp):
diff --git a/pypy/rpython/lltypesystem/test/test_rffi.py 
b/pypy/rpython/lltypesystem/test/test_rffi.py
--- a/pypy/rpython/lltypesystem/test/test_rffi.py
+++ b/pypy/rpython/lltypesystem/test/test_rffi.py
@@ -743,8 +743,9 @@
             assert sizeof(lltype.Typedef(ll, 'test')) == sizeof(ll)
         assert not size_and_sign(lltype.Signed)[1]
         assert size_and_sign(lltype.Char) == (1, True)
-        assert not size_and_sign(lltype.UniChar)[1]
+        assert size_and_sign(lltype.UniChar)[1]
         assert size_and_sign(UINT)[1]
+        assert not size_and_sign(INT)[1]
     
     def test_rffi_offsetof(self):
         import struct
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to