[pypy-svn] r50590 - in pypy/branch/applevel-ctypes2/pypy/rpython/lltypesystem: . test
arigo at codespeak.net
arigo at codespeak.net
Mon Jan 14 14:25:56 CET 2008
Author: arigo
Date: Mon Jan 14 14:25:55 2008
New Revision: 50590
Modified:
pypy/branch/applevel-ctypes2/pypy/rpython/lltypesystem/ll2ctypes.py
pypy/branch/applevel-ctypes2/pypy/rpython/lltypesystem/test/test_ll2ctypes.py
Log:
(fijal, arigo)
ctypes bites again.
Modified: pypy/branch/applevel-ctypes2/pypy/rpython/lltypesystem/ll2ctypes.py
==============================================================================
--- pypy/branch/applevel-ctypes2/pypy/rpython/lltypesystem/ll2ctypes.py (original)
+++ pypy/branch/applevel-ctypes2/pypy/rpython/lltypesystem/ll2ctypes.py Mon Jan 14 14:25:55 2008
@@ -619,6 +619,8 @@
return ctypes2lltype(RESTYPE, cptr)
# first cast the input pointer to an integer
cvalue = ctypes.cast(cvalue, ctypes.c_void_p).value
+ if cvalue is None:
+ cvalue = 0
elif isinstance(cvalue, (str, unicode)):
cvalue = ord(cvalue) # character -> integer
Modified: pypy/branch/applevel-ctypes2/pypy/rpython/lltypesystem/test/test_ll2ctypes.py
==============================================================================
--- pypy/branch/applevel-ctypes2/pypy/rpython/lltypesystem/test/test_ll2ctypes.py (original)
+++ pypy/branch/applevel-ctypes2/pypy/rpython/lltypesystem/test/test_ll2ctypes.py Mon Jan 14 14:25:55 2008
@@ -332,6 +332,10 @@
for i in range(10):
assert e[i] == i*i
+ c = lltype.nullptr(rffi.VOIDP.TO)
+ addr = rffi.cast(lltype.Signed, c)
+ assert addr == 0
+
lltype.free(a, flavor='raw')
assert not ALLOCATED # detects memory leaks in the test
More information about the Pypy-commit
mailing list