Ctypes error

Discussion in 'Python' started by Michele Petrazzo, Oct 7, 2004.

  1. 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
     
    Michele Petrazzo, Oct 7, 2004
    #1
    1. Advertising

  2. Michele Petrazzo <> 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
     
    Thomas Heller, Oct 7, 2004
    #2
    1. Advertising

  3. Michele Petrazzo

    Thomas Rast Guest

    Thomas Heller <> writes:

    > 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

    --
    If you want to reply by mail, substitute my first and last name for
    'foo' and 'bar', respectively, and remove '.invalid'.
     
    Thomas Rast, Oct 8, 2004
    #3
  4. Thomas Rast <> writes:

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


    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
     
    Thomas Heller, Oct 8, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Henk Punt
    Replies:
    0
    Views:
    426
    Henk Punt
    Jul 23, 2004
  2. Max M
    Replies:
    4
    Views:
    789
    Max M
    Oct 7, 2004
  3. Martin P. Hellwig
    Replies:
    3
    Views:
    502
    Martin P. Hellwig
    Jul 15, 2006
  4. Mudcat
    Replies:
    6
    Views:
    1,065
    Bruno Desthuilliers
    Oct 31, 2006
  5. Replies:
    0
    Views:
    539
Loading...

Share This Page