1. Pypy
  2. Untitled project
  3. pypy

Commits

Armin Rigo  committed 914c562

Fix.

  • Participants
  • Parent commits 14495ad
  • Branches default

Comments (0)

Files changed (2)

File pypy/rpython/lltypesystem/rffi.py

View file
  • Ignore whitespace
     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):

File pypy/rpython/lltypesystem/test/test_rffi.py

View file
  • Ignore whitespace
             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