diff options
author | Thomas Heller <theller@ctypes.org> | 2007-07-12 19:19:43 (GMT) |
---|---|---|
committer | Thomas Heller <theller@ctypes.org> | 2007-07-12 19:19:43 (GMT) |
commit | 7775c716fcf28346e2e79238d6e5080d5a1bcc81 (patch) | |
tree | e5adb2863214cf0e308006e60b27c9afcd45aeed /Modules | |
parent | 60831316df8893e973f92592b7c4c95ad489ff15 (diff) | |
download | cpython-7775c716fcf28346e2e79238d6e5080d5a1bcc81.zip cpython-7775c716fcf28346e2e79238d6e5080d5a1bcc81.tar.gz cpython-7775c716fcf28346e2e79238d6e5080d5a1bcc81.tar.bz2 |
Accept bytes as parameter to foreign functions without prototype.
These are passed as byte strings (unicode strings are passed as wide
character strings).
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ctypes/callproc.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index 23150b3..6380b1a 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -512,6 +512,7 @@ static int ConvParam(PyObject *obj, Py_ssize_t index, struct argument *pa) return 0; } + /* XXX struni remove later */ if (PyString_Check(obj)) { pa->ffi_type = &ffi_type_pointer; pa->value.p = PyString_AS_STRING(obj); @@ -520,6 +521,14 @@ static int ConvParam(PyObject *obj, Py_ssize_t index, struct argument *pa) return 0; } + if (PyBytes_Check(obj)) { + pa->ffi_type = &ffi_type_pointer; + pa->value.p = PyBytes_AsString(obj); + Py_INCREF(obj); + pa->keep = obj; + return 0; + } + #ifdef CTYPES_UNICODE if (PyUnicode_Check(obj)) { #ifdef HAVE_USABLE_WCHAR_T |