Bugs item #1723338, was opened at 2007-05-22 12:43 Message generated for change (Comment added) made by theller You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1723338&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Extension Modules Group: Python 2.5 >Status: Closed Resolution: Works For Me Priority: 5 Private: No Submitted By: Colin Laplace (claplace) Assigned to: Thomas Heller (theller) Summary: Crash in ctypes callproc function with unicode string arg Initial Comment: I've recently came to a bug using ctypes. I was using ctypes to call a syscall and and passing it a string argument, which was in fact in unicode. This resulted in a python crash in the callproc function. You can easily reproduce the crash by launching the attached python file (or at this link: https://core.fluendo.com/elisa/trac/browser/branches/rewrite-1/elisa/extern/inotify.py ) tested with python 2.5 ---------------------------------------------------------------------- >Comment By: Thomas Heller (theller) Date: 2007-05-28 17:39 Message: Logged In: YES user_id=11105 Originator: NO Thanks, closing then. ---------------------------------------------------------------------- Comment By: Colin Laplace (claplace) Date: 2007-05-28 11:58 Message: Logged In: YES user_id=25510 Originator: YES The argtypes thing fixed my problem, thank you. ---------------------------------------------------------------------- Comment By: Thomas Heller (theller) Date: 2007-05-23 20:35 Message: Logged In: YES user_id=11105 Originator: NO Unfortunately your test script does not run for me (I don't have twisted installed on Linux). I fear this is not a bug. When the .argtypes attribute for a foreign function is not set, you can pass (among others) Python strings *and* Python unicode strings to the function. The foreign function will receive a 'char *' in the former case, and a 'wchar_t *' in the latter case - the unicode string will *not* be converted. If this is your problem, and the foreign function expects a 'char *', you have several choices: 1. You can convert the unicode string to an ascii string in the Python code yourself. 2. You can wrap the unicode string in a c_char_p instance, and ctypes will do the conversion for you. 3. You can set the correct .argtypes attribute on the function, and ctypes will do the conversion for you. If this is not your problem, please provide a self-contained test case. ---------------------------------------------------------------------- Comment By: Neal Norwitz (nnorwitz) Date: 2007-05-23 06:06 Message: Logged In: YES user_id=33168 Originator: NO Thomas, could you take a look? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1723338&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com