[issue7505] ctypes not converting None to Null in 64-bit system

2010-02-09 Thread Venkateswaran

Venkateswaran  added the comment:

The output was a valid pointer which was not null. I did not investigate 
further on this issue, because I had a work around i.e I used 
ctypes.POINTER(ctypes.c_cint)() instead of None.

--

___
Python tracker 
<http://bugs.python.org/issue7505>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7505] ctypes not converting None to Null in 64-bit system

2009-12-14 Thread Venkateswaran

New submission from Venkateswaran :

The attached code is failing to convert None to Null. It is successful 
if the int* is shifted towards the beginning of argument list. The bug 
is actually in 32/64 bit pointers as the code works on a 32 bit system.

The bug disappears if I reduce the number of arguments to less than 10.

I created the so using the command - "gcc  -shared -fPIC  -o libtest.so 
libtest.c", (gcc (Debian 4.3.2-1.1) 4.3.2) 

The c file is as follows:

libtest.c
#include 
#include 


int32_t where ( int32_t a, int32_t c, int32_t d, int32_t e, int32_t f, 
int32_t g, int32_t h, int32_t *b, int32_t i, int32_t j, int32_t k, 
int32_t l)
{
printf("b = %p\n", (void *)b);
printf("a = %d, c = %d, d = %d, e = %d, f = %d, g = %d, h = %d, i = 
%d, j = %d, k = %d,  l = %d", a,c,d,e,f,g,h,i,j,k,l);

return 100;

} /* where() */

Python Code:
import ctypes

libtest = ctypes.CDLL('./libtest.so')
where = libtest.where
where.restype = ctypes.c_int
where.argtypes = [ 
ctypes.c_int32, ctypes.c_int32, ctypes.c_int32,  
ctypes.c_int32, ctypes.c_int32, ctypes.c_int32, ctypes.c_int32,
ctypes.POINTER(ctypes.c_int32),
ctypes.c_int32, ctypes.c_int32, ctypes.c_int32, 
ctypes.c_int32,
 ]


a = 7
b = None

status = where(a,a,a,a,a,a,a,b,a,a,a,a)

--
assignee: theller
components: ctypes
files: test.py
messages: 96385
nosy: theller, wenkat_s
severity: normal
status: open
title: ctypes not converting None to Null in 64-bit system
type: crash
versions: Python 2.5, Python 2.6
Added file: http://bugs.python.org/file15557/test.py

___
Python tracker 
<http://bugs.python.org/issue7505>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com