[pypy-svn] r78158 - in pypy/trunk/pypy/rpython/lltypesystem: . test
arigo at codespeak.net
arigo at codespeak.net
Thu Oct 21 11:45:03 CEST 2010
Author: arigo
Date: Thu Oct 21 11:45:02 2010
New Revision: 78158
Modified:
pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py
pypy/trunk/pypy/rpython/lltypesystem/test/test_rffi.py
Log:
Test and fix.
Modified: pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py (original)
+++ pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py Thu Oct 21 11:45:02 2010
@@ -823,6 +823,8 @@
except (ValueError, OverflowError):
for tc in 'HIL':
if array(tc).itemsize == array('u').itemsize:
+ import struct
+ cobj &= 256 ** struct.calcsize(tc) - 1
llobj = array('u', array(tc, (cobj,)).tostring())[0]
break
else:
Modified: pypy/trunk/pypy/rpython/lltypesystem/test/test_rffi.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/test/test_rffi.py (original)
+++ pypy/trunk/pypy/rpython/lltypesystem/test/test_rffi.py Thu Oct 21 11:45:02 2010
@@ -787,3 +787,10 @@
mixann.getgraph(f2, [], s_None)
mixann.finish()
+def test_force_cast_unichar():
+ x = cast(lltype.UniChar, -1)
+ assert isinstance(x, unicode)
+ if sys.maxunicode == 65535:
+ assert cast(LONG, x) == 65535
+ else:
+ assert cast(LONG, cast(INT, x)) == -1
More information about the Pypy-commit
mailing list