Ctypes error

  • Thread starter Michele Petrazzo
  • Start date
M

Michele Petrazzo

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
 
T

Thomas Heller

Michele Petrazzo said:
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
 
T

Thomas Rast

Thomas Heller said:
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.

Since nobody else replied, I'll have to speak up here :)

I'm running a stock Debian 'testing' Linux, which currently means

libc6 2.3.2.ds1-16
gcc 3.3.4-2
python 2.3.4-4

/usr/include/python2.3/pyconfig.h *does* define HAVE_USABLE_WCHAR_T.

- Thomas
 
T

Thomas Heller

Thomas Rast said:
Since nobody else replied, I'll have to speak up here :)

I'm running a stock Debian 'testing' Linux, which currently means

libc6 2.3.2.ds1-16
gcc 3.3.4-2
python 2.3.4-4

/usr/include/python2.3/pyconfig.h *does* define HAVE_USABLE_WCHAR_T.

Thanks for the effort - on my suse linux 9.0 with gcc 3.3.1,
HAVE_USABLE_WCHAR_T is *not* defined - neither with the python package
that suse delivers, nor with ./configure I run myself over the CVS
sources.

But the good news is - it doesn't matter. I posted a mssage to
python-dev about my finding when grepping through the sources - ctypes
should use HAVE_WCHAR_H, or maybe Py_UNICODE_SIZE.

http://mail.python.org/pipermail/python-dev/2004-October/049275.html

Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top