[Python-checkins] r52388 - in python/trunk/Modules: _ctypes/callproc.c _ssl.c audioop.c dbmmodule.c

martin.v.loewis python-checkins at python.org
Thu Oct 19 13:00:38 CEST 2006


Author: martin.v.loewis
Date: Thu Oct 19 13:00:37 2006
New Revision: 52388

Modified:
   python/trunk/Modules/_ctypes/callproc.c
   python/trunk/Modules/_ssl.c
   python/trunk/Modules/audioop.c
   python/trunk/Modules/dbmmodule.c
Log:
Fix various minor errors in passing arguments to 
PyArg_ParseTuple.


Modified: python/trunk/Modules/_ctypes/callproc.c
==============================================================================
--- python/trunk/Modules/_ctypes/callproc.c	(original)
+++ python/trunk/Modules/_ctypes/callproc.c	Thu Oct 19 13:00:37 2006
@@ -1247,11 +1247,11 @@
 
 static PyObject *py_dl_close(PyObject *self, PyObject *args)
 {
-	void * handle;
+	int handle;
 
 	if (!PyArg_ParseTuple(args, "i:dlclose", &handle))
 		return NULL;
-	if (dlclose(handle)) {
+	if (dlclose((void*)handle)) {
 		PyErr_SetString(PyExc_OSError,
 				       ctypes_dlerror());
 		return NULL;
@@ -1263,12 +1263,12 @@
 static PyObject *py_dl_sym(PyObject *self, PyObject *args)
 {
 	char *name;
-	void *handle;
+	int handle;
 	void *ptr;
 
 	if (!PyArg_ParseTuple(args, "is:dlsym", &handle, &name))
 		return NULL;
-	ptr = ctypes_dlsym(handle, name);
+	ptr = ctypes_dlsym((void*)handle, name);
 	if (!ptr) {
 		PyErr_SetString(PyExc_OSError,
 				       ctypes_dlerror());
@@ -1286,7 +1286,7 @@
 static PyObject *
 call_function(PyObject *self, PyObject *args)
 {
-	PPROC func;
+	int func;
 	PyObject *arguments;
 	PyObject *result;
 
@@ -1296,7 +1296,7 @@
 			      &PyTuple_Type, &arguments))
 		return NULL;
 
-	result =  _CallProc(func,
+	result =  _CallProc((PPROC)func,
 			    arguments,
 #ifdef MS_WIN32
 			    NULL,
@@ -1317,7 +1317,7 @@
 static PyObject *
 call_cdeclfunction(PyObject *self, PyObject *args)
 {
-	PPROC func;
+	int func;
 	PyObject *arguments;
 	PyObject *result;
 
@@ -1327,7 +1327,7 @@
 			      &PyTuple_Type, &arguments))
 		return NULL;
 
-	result =  _CallProc(func,
+	result =  _CallProc((PPROC)func,
 			    arguments,
 #ifdef MS_WIN32
 			    NULL,
@@ -1510,7 +1510,7 @@
 #else
 			      "On:resize",
 #endif
-			      (PyObject *)&obj, &size))
+			      &obj, &size))
 		return NULL;
 
 	dict = PyObject_stgdict((PyObject *)obj);

Modified: python/trunk/Modules/_ssl.c
==============================================================================
--- python/trunk/Modules/_ssl.c	(original)
+++ python/trunk/Modules/_ssl.c	Thu Oct 19 13:00:37 2006
@@ -317,7 +317,7 @@
 
 	if (!PyArg_ParseTuple(args, "O!|zz:ssl",
 			      PySocketModule.Sock_Type,
-			      (PyObject*)&Sock,
+			      &Sock,
 			      &key_file, &cert_file))
 		return NULL;
 

Modified: python/trunk/Modules/audioop.c
==============================================================================
--- python/trunk/Modules/audioop.c	(original)
+++ python/trunk/Modules/audioop.c	Thu Oct 19 13:00:37 2006
@@ -472,8 +472,12 @@
         double aj_m1, aj_lm1;
         double sum_ri_2, sum_aij_2, sum_aij_ri, result, best_result, factor;
 
+	/* Passing a short** for an 's' argument is correct only
+	   if the string contents is aligned for interpretation
+	   as short[]. Due to the definition of PyStringObject,
+	   this is currently (Python 2.6) the case. */
         if ( !PyArg_ParseTuple(args, "s#s#:findfit",
-	                       &cp1, &len1, &cp2, &len2) )
+	                       (char**)&cp1, &len1, (char**)&cp2, &len2) )
                 return 0;
         if ( len1 & 1 || len2 & 1 ) {
                 PyErr_SetString(AudioopError, "Strings should be even-sized");
@@ -530,7 +534,7 @@
         double sum_ri_2, sum_aij_ri, result;
 
         if ( !PyArg_ParseTuple(args, "s#s#:findfactor",
-	                       &cp1, &len1, &cp2, &len2) )
+	                       (char**)&cp1, &len1, (char**)&cp2, &len2) )
                 return 0;
         if ( len1 & 1 || len2 & 1 ) {
                 PyErr_SetString(AudioopError, "Strings should be even-sized");
@@ -562,7 +566,8 @@
         double aj_m1, aj_lm1;
         double result, best_result;
 
-        if ( !PyArg_ParseTuple(args, "s#i:findmax", &cp1, &len1, &len2) )
+        if ( !PyArg_ParseTuple(args, "s#i:findmax", 
+			       (char**)&cp1, &len1, &len2) )
                 return 0;
         if ( len1 & 1 ) {
                 PyErr_SetString(AudioopError, "Strings should be even-sized");

Modified: python/trunk/Modules/dbmmodule.c
==============================================================================
--- python/trunk/Modules/dbmmodule.c	(original)
+++ python/trunk/Modules/dbmmodule.c	Thu Oct 19 13:00:37 2006
@@ -208,11 +208,13 @@
 static PyObject *
 dbm_has_key(register dbmobject *dp, PyObject *args)
 {
+	char *tmp_ptr;
 	datum key, val;
 	int tmp_size;
 	
-	if (!PyArg_ParseTuple(args, "s#:has_key", &key.dptr, &tmp_size))
+	if (!PyArg_ParseTuple(args, "s#:has_key", &tmp_ptr, &tmp_size))
 		return NULL;
+	key.dptr = tmp_ptr;
 	key.dsize = tmp_size;
         check_dbmobject_open(dp);
 	val = dbm_fetch(dp->di_dbm, key);
@@ -224,11 +226,13 @@
 {
 	datum key, val;
 	PyObject *defvalue = Py_None;
+	char *tmp_ptr;
 	int tmp_size;
 
 	if (!PyArg_ParseTuple(args, "s#|O:get",
-                              &key.dptr, &tmp_size, &defvalue))
+                              &tmp_ptr, &tmp_size, &defvalue))
 		return NULL;
+	key.dptr = tmp_ptr;
 	key.dsize = tmp_size;
         check_dbmobject_open(dp);
 	val = dbm_fetch(dp->di_dbm, key);
@@ -245,11 +249,13 @@
 {
 	datum key, val;
 	PyObject *defvalue = NULL;
+	char *tmp_ptr;
 	int tmp_size;
 
 	if (!PyArg_ParseTuple(args, "s#|S:setdefault",
-                              &key.dptr, &tmp_size, &defvalue))
+                              &tmp_ptr, &tmp_size, &defvalue))
 		return NULL;
+	key.dptr = tmp_ptr;
 	key.dsize = tmp_size;
         check_dbmobject_open(dp);
 	val = dbm_fetch(dp->di_dbm, key);


More information about the Python-checkins mailing list