Static wchar array becomes str object, why?

Hi all, this is my code. Please take look. Here, I am passing a static wchar array to a python function and python treats it as str object. Can you explain why and how to prevent this ?

from ctypes.wintypes import INT, WCHAR
import ctypes as ct
class FOO(ct.Structure):
    _fields_ = [
        ('x', INT),
        ('y', INT),
        ('arr', WCHAR * 32)
    ]
def fillBuffer(buffer, txt):
    print(type(buffer))

foo = FOO()
fillBuffer(foo.arr, "Apple")
# It prints <class 'str'>

A str is just the type that Python maps "c_wchar"s too. It can only be assumed they really are static wchar arrays, in the C code being interfaced with.

WCHAR = ctypes.c_wchar

That’s the interesting part. I tried with USHORT and it treated the parameter as a str. I don’t know how to handle this. Let me explain why I am doing this. I have a GUI lib with win api functions. Last day, I tried to improve the performance of font related functions, and I found that I can speed up things by using the lfFaceName member of LOGFONTW structure. It is a static array which can hold 32 characters. So I am trying to pass the array pointer to MultiByteToWideChar function.

It is assumed that a wchar_t array will contain utf-16 characters.
Which is exactly what a WIN32 function want usually.

Did you mean to init foo.arr with “Apple”?
Becuase the codes does not do that anywhere.

Thank you for the reply. I am sorry, I didn’t give the full code. But this is what I want to do.
I tried to improve the performance of font related functions in gui lib, and I found that I can speed up things by using the lfFaceName member of LOGFONTW structure. It is a static array which can hold 32 characters. So I am trying to pass the array pointer to MultiByteToWideChar function.

All WIN32 APIs use unicode in wchar_t arrays.
Where are you getting the MultiByte sequence from?

Just a wild guess but are you assuming that python strings are MultiByte?
And therefore you need to convert the python string to wchar_t?