Merge remote-tracking branch 'oe21/master' into vuplus-3.0
[vuplus_openvuplus_3.0] / meta-openvuplus / recipes-devtools / python / python / ctypes-error-handling-fix.patch
1 diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
2 index 4ae2c41..ebd9960 100644
3 --- a/Modules/_ctypes/_ctypes.c
4 +++ b/Modules/_ctypes/_ctypes.c
5 @@ -602,10 +602,16 @@ CDataType_in_dll(PyObject *type, PyObject *args)
6  #ifdef __CYGWIN__
7  /* dlerror() isn't very helpful on cygwin */
8          PyErr_Format(PyExc_ValueError,
9 -                     "symbol '%s' not found (%s) ",
10 +                     "symbol '%s' not found",
11                       name);
12  #else
13 -        PyErr_SetString(PyExc_ValueError, ctypes_dlerror());
14 +        const char *err = ctypes_dlerror();
15 +        if (!err)
16 +            PyErr_Format(PyExc_ValueError,
17 +                         "symbol '%s' not found",
18 +                         name);
19 +        else
20 +            PyErr_SetString(PyExc_ValueError, err);
21  #endif
22          return NULL;
23      }
24 @@ -3343,10 +3349,16 @@ PyCFuncPtr_FromDll(PyTypeObject *type, PyObject *args, PyObject *kwds)
25  #ifdef __CYGWIN__
26  /* dlerror() isn't very helpful on cygwin */
27          PyErr_Format(PyExc_AttributeError,
28 -                     "function '%s' not found (%s) ",
29 +                     "function '%s' not found",
30                       name);
31  #else
32 -        PyErr_SetString(PyExc_AttributeError, ctypes_dlerror());
33 +        const char *err = ctypes_dlerror();
34 +        if (!err)
35 +            PyErr_Format(PyExc_AttributeError,
36 +                         "function '%s' not found",
37 +                         name);
38 +        else
39 +            PyErr_SetString(PyExc_AttributeError, err);
40  #endif
41          return NULL;
42      }