[ctypes-commit] ctypes/ctypes __init__.py,1.31,1.32
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2004-09-07 06:37:46
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15543 Modified Files: __init__.py Log Message: Fix the create_unicode_buffer function - it was returning c_char arrays instead of c_wchar arrays. Both create_string_buffer and create_unicode_buffer can now be called with string and unicode instances, they will do the needed conversions themselves. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** __init__.py 1 Sep 2004 11:55:05 -0000 1.31 --- __init__.py 7 Sep 2004 06:37:36 -0000 1.32 *************** *** 42,46 **** create_string_buffer(aString, anInteger) -> character array """ ! if isinstance(init, str): if size is None: size = len(init)+1 --- 42,47 ---- create_string_buffer(aString, anInteger) -> character array """ ! if isinstance(init, (str, unicode)): ! init = str(init) if size is None: size = len(init)+1 *************** *** 60,72 **** create_unicode_buffer(aString, anInteger) -> character array """ ! if isinstance(init, str): if size is None: size = len(init)+1 ! buftype = c_char * size buf = buftype() buf.value = init return buf elif isinstance(init, (int, long)): ! buftype = c_char * init buf = buftype() return buf --- 61,74 ---- create_unicode_buffer(aString, anInteger) -> character array """ ! if isinstance(init, (str, unicode)): ! init = unicode(init) if size is None: size = len(init)+1 ! buftype = c_wchar * size buf = buftype() buf.value = init return buf elif isinstance(init, (int, long)): ! buftype = c_wchar * init buf = buftype() return buf |