Index: Modules/_ctypes/callproc.c =================================================================== --- Modules/_ctypes/callproc.c (révision 80063) +++ Modules/_ctypes/callproc.c (copie de travail) @@ -92,7 +92,7 @@ ctypes maintains thread-local storage that has space for two error numbers: private copies of the system 'errno' value and, on Windows, the system error code accessed by the GetLastError() and SetLastError() api functions. - + Foreign functions created with CDLL(..., use_errno=True), when called, swap the system 'errno' value with the private copy just before the actual function call, and swapped again immediately afterwards. The 'use_errno' @@ -289,7 +289,7 @@ "exception: single step"); break; - case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: + case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: /* The thread attempted to access an array element that is out of bounds, and the underlying hardware supports bounds checking. */ @@ -462,7 +462,7 @@ sprintf(buffer, "", self->tag, self->value.l); break; - + #ifdef HAVE_LONG_LONG case 'q': case 'Q': @@ -703,7 +703,7 @@ return result; } PyErr_Format(PyExc_TypeError, - "Don't know how to convert parameter %d", + "Don't know how to convert parameter %d", Py_SAFE_DOWNCAST(index, Py_ssize_t, int)); return -1; } @@ -773,7 +773,7 @@ "No ffi_type for result"); return -1; } - + cc = FFI_DEFAULT_ABI; #if defined(MS_WIN32) && !defined(MS_WIN64) && !defined(_WIN32_WCE) if ((flags & FUNCFLAG_CDECL) == 0) @@ -1147,7 +1147,7 @@ } for (i = 0; i < argcount; ++i) { atypes[i] = args[i].ffi_type; - if (atypes[i]->type == FFI_TYPE_STRUCT + if (atypes[i]->type == FFI_TYPE_STRUCT #ifdef _WIN64 && atypes[i]->size <= sizeof(void *) #endif @@ -1371,18 +1371,25 @@ static PyObject *py_dl_open(PyObject *self, PyObject *args) { - char *name; + PyObject *name; + char *name_str; void * handle; -#ifdef RTLD_LOCAL +#ifdef RTLD_LOCAL int mode = RTLD_NOW | RTLD_LOCAL; #else /* cygwin doesn't define RTLD_LOCAL */ int mode = RTLD_NOW; #endif - if (!PyArg_ParseTuple(args, "z|i:dlopen", &name, &mode)) + if (!PyArg_ParseTuple(args, "O&|i:dlopen", + PyUnicode_FSConverter, &name, &mode)) return NULL; mode |= RTLD_NOW; - handle = ctypes_dlopen(name, mode); + if (PyBytes_Check(name)) + name_str = PyBytes_AS_STRING(name); + else + name_str = PyByteArray_AS_STRING(name); + handle = ctypes_dlopen(name_str, mode); + Py_XDECREF(name); if (!handle) { char *errmsg = ctypes_dlerror(); if (!errmsg)