[Python-checkins] r80159 - in python/branches/py3k: Misc/NEWS Modules/_ctypes/callproc.c
victor.stinner
python-checkins at python.org
Sun Apr 18 02:00:44 CEST 2010
Author: victor.stinner
Date: Sun Apr 18 02:00:44 2010
New Revision: 80159
Log:
Issue #8394: _ctypes.dlopen() accepts bytes, bytearray and str with
surrogates.
Modified:
python/branches/py3k/Misc/NEWS
python/branches/py3k/Modules/_ctypes/callproc.c
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Sun Apr 18 02:00:44 2010
@@ -315,6 +315,9 @@
Library
-------
+- Issue #8394: _ctypes.dlopen() accepts bytes, bytearray and str with
+ surrogates.
+
- Issue #850728: Add a *timeout* parameter to the `acquire()` method of
`threading.Semaphore` objects. Original patch by Torsten Landschoff.
Modified: python/branches/py3k/Modules/_ctypes/callproc.c
==============================================================================
--- python/branches/py3k/Modules/_ctypes/callproc.c (original)
+++ python/branches/py3k/Modules/_ctypes/callproc.c Sun Apr 18 02:00:44 2010
@@ -1371,7 +1371,8 @@
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 @@
/* 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)
More information about the Python-checkins
mailing list