Ctypes error
Thomas Heller
theller at python.net
Thu Oct 7 14:40:13 EDT 2004
Michele Petrazzo <michele.petrazzo at TOGLIunipex.it> writes:
> I'm using ctypes v 0.9.1 on linux for the first time.
>
> Then I try to use create_unicode_buffer(), I receive this error:
>
> File "/usr/lib/python2.3/site-packages/ctypes/__init__.py", line 74,
> in create_unicode_buffer
> buftype = c_wchar * init
> NameError: global name 'c_wchar' is not defined
>
> In __init__ file I see that at line:
> 208 if _os.name == "nt":
> 214 class c_wchar(_SimpleCData):
>
> This class if only for "nt" ?
>
> Thanks,
> Michele Petrazzo
Ok, it seems I missed to put the create_unicode_buffer inside an if:
if os.name == "nt":
The deeper issue is that the unicode stuff in ctypes is only compiled in
when the Python header files define the HAVE_USABLE_WCHAR_T symbol. Of
the systems I build and test on, only Windows defines this.
I'm not really sure that this is really the right thing to do,
maybe this should be sufficient:
#if Py_UNICODE_SIZE == 2
Thomas
More information about the Python-list
mailing list