summaryrefslogtreecommitdiff
path: root/Modules/_ctypes/_ctypes.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_ctypes/_ctypes.c')
-rw-r--r--Modules/_ctypes/_ctypes.c36
1 files changed, 14 insertions, 22 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 2935292a50..b3a95811eb 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -111,12 +111,6 @@ bytes(cdata)
#ifndef IS_INTRESOURCE
#define IS_INTRESOURCE(x) (((size_t)(x) >> 16) == 0)
#endif
-# ifdef _WIN32_WCE
-/* Unlike desktop Windows, WinCE has both W and A variants of
- GetProcAddress, but the default W version is not what we want */
-# undef GetProcAddress
-# define GetProcAddress GetProcAddressA
-# endif
#else
#include "ctypes_dlfcn.h"
#endif
@@ -435,7 +429,7 @@ UnionType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return StructUnionType_new(type, args, kwds, 0);
}
-static char from_address_doc[] =
+static const char from_address_doc[] =
"C.from_address(integer) -> C instance\naccess a C instance at the specified address";
static PyObject *
@@ -453,7 +447,7 @@ CDataType_from_address(PyObject *type, PyObject *value)
return PyCData_AtAddress(type, buf);
}
-static char from_buffer_doc[] =
+static const char from_buffer_doc[] =
"C.from_buffer(object, offset=0) -> C instance\ncreate a C instance from a writeable buffer";
static int
@@ -524,7 +518,7 @@ CDataType_from_buffer(PyObject *type, PyObject *args)
return result;
}
-static char from_buffer_copy_doc[] =
+static const char from_buffer_copy_doc[] =
"C.from_buffer_copy(object, offset=0) -> C instance\ncreate a C instance from a readable buffer";
static PyObject *
@@ -566,7 +560,7 @@ CDataType_from_buffer_copy(PyObject *type, PyObject *args)
return result;
}
-static char in_dll_doc[] =
+static const char in_dll_doc[] =
"C.in_dll(dll, name) -> C instance\naccess a C instance in a dll";
static PyObject *
@@ -623,7 +617,7 @@ CDataType_in_dll(PyObject *type, PyObject *args)
return PyCData_AtAddress(type, address);
}
-static char from_param_doc[] =
+static const char from_param_doc[] =
"Convert a Python object into a function call parameter.";
static PyObject *
@@ -1489,7 +1483,7 @@ _type_ attribute.
*/
-static char *SIMPLE_TYPE_CHARS = "cbBhHiIlLdfuzZqQPXOv?g";
+static const char SIMPLE_TYPE_CHARS[] = "cbBhHiIlLdfuzZqQPXOv?g";
static PyObject *
c_wchar_p_from_param(PyObject *type, PyObject *value)
@@ -2414,7 +2408,7 @@ unique_key(CDataObject *target, Py_ssize_t index)
char *cp = string;
size_t bytes_left;
- assert(sizeof(string) - 1 > sizeof(Py_ssize_t) * 2);
+ Py_BUILD_ASSERT(sizeof(string) - 1 > sizeof(Py_ssize_t) * 2);
cp += sprintf(cp, "%x", Py_SAFE_DOWNCAST(index, Py_ssize_t, int));
while (target->b_base) {
bytes_left = sizeof(string) - (cp - string) - 1;
@@ -3075,7 +3069,7 @@ static PyGetSetDef PyCFuncPtr_getsets[] = {
};
#ifdef MS_WIN32
-static PPROC FindAddress(void *handle, char *name, PyObject *type)
+static PPROC FindAddress(void *handle, const char *name, PyObject *type)
{
#ifdef MS_WIN64
/* win64 has no stdcall calling conv, so it should
@@ -3209,7 +3203,7 @@ _validate_paramflags(PyTypeObject *type, PyObject *paramflags)
}
static int
-_get_name(PyObject *obj, char **pname)
+_get_name(PyObject *obj, const char **pname)
{
#ifdef MS_WIN32
if (PyLong_Check(obj)) {
@@ -3237,7 +3231,7 @@ _get_name(PyObject *obj, char **pname)
static PyObject *
PyCFuncPtr_FromDll(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
- char *name;
+ const char *name;
int (* address)(void);
PyObject *ftuple;
PyObject *dll;
@@ -5127,13 +5121,12 @@ static const char module_docs[] =
#ifdef MS_WIN32
-static char comerror_doc[] = "Raised when a COM method call failed.";
+static const char comerror_doc[] = "Raised when a COM method call failed.";
int
comerror_init(PyObject *self, PyObject *args, PyObject *kwds)
{
PyObject *hresult, *text, *details;
- PyBaseExceptionObject *bself;
PyObject *a;
int status;
@@ -5160,9 +5153,8 @@ comerror_init(PyObject *self, PyObject *args, PyObject *kwds)
if (PyObject_SetAttrString(self, "details", details) < 0)
return -1;
- bself = (PyBaseExceptionObject *)self;
Py_INCREF(args);
- Py_SETREF(bself->args, args);
+ Py_SETREF(((PyBaseExceptionObject *)self)->args, args);
return 0;
}
@@ -5492,14 +5484,14 @@ PyInit__ctypes(void)
#endif
/* If RTLD_LOCAL is not defined (Windows!), set it to zero. */
-#ifndef RTLD_LOCAL
+#if !HAVE_DECL_RTLD_LOCAL
#define RTLD_LOCAL 0
#endif
/* If RTLD_GLOBAL is not defined (cygwin), set it to the same value as
RTLD_LOCAL.
*/
-#ifndef RTLD_GLOBAL
+#if !HAVE_DECL_RTLD_GLOBAL
#define RTLD_GLOBAL RTLD_LOCAL
#endif