eryksun added the comment:

You need to cast to a pointer type, i.e. POINTER(Struct). Trying to cast to 
just Struct should raise a TypeError. Instead this revealed a bug in 
cast_check_pointertype (3.4.1):

http://hg.python.org/cpython/file/c0e311e010fc/Modules/_ctypes/_ctypes.c#l5225

dict->proto is NULL in the Struct type's stgdict, so 
PyUnicode_Check(dict->proto) segfaults. A simple fix is to add a check for this 
on line 5235:

    if (dict && dict->proto) {

Then cast will raise the expected TypeError from line 5242 on return from line 
5255.

----------
nosy: +eryksun

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21983>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to