diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-04-18 00:03:40 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-04-18 00:03:40 (GMT) |
commit | ba1f449ca2f7c118cf736fc67f63d4747b36059e (patch) | |
tree | 6b132c6e42afbfc94eba0fcd33bb5a9a2ab117e6 /Modules | |
parent | 6ffdb6f921c1be37ce3679fe73e211c01942427a (diff) | |
download | cpython-ba1f449ca2f7c118cf736fc67f63d4747b36059e.zip cpython-ba1f449ca2f7c118cf736fc67f63d4747b36059e.tar.gz cpython-ba1f449ca2f7c118cf736fc67f63d4747b36059e.tar.bz2 |
Merged revisions 80159 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r80159 | victor.stinner | 2010-04-18 02:00:44 +0200 (dim., 18 avril 2010) | 3 lines
Issue #8394: _ctypes.dlopen() accepts bytes, bytearray and str with
surrogates.
........
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ctypes/callproc.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index 2a75fb1..022cceb 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -1371,7 +1371,8 @@ copy_com_pointer(PyObject *self, PyObject *args) static PyObject *py_dl_open(PyObject *self, PyObject *args) { - char *name; + PyObject *name, *name2; + char *name_str; void * handle; #ifdef RTLD_LOCAL int mode = RTLD_NOW | RTLD_LOCAL; @@ -1379,10 +1380,22 @@ static PyObject *py_dl_open(PyObject *self, PyObject *args) /* 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", &name, &mode)) return NULL; mode |= RTLD_NOW; - handle = ctypes_dlopen(name, mode); + if (name != Py_None) { + if (PyUnicode_FSConverter(name, &name2) == 0) + return NULL; + if (PyBytes_Check(name2)) + name_str = PyBytes_AS_STRING(name2); + else + name_str = PyByteArray_AS_STRING(name2); + } else { + name_str = NULL; + name2 = NULL; + } + handle = ctypes_dlopen(name_str, mode); + Py_XDECREF(name2); if (!handle) { char *errmsg = ctypes_dlerror(); if (!errmsg) |