mirror of
https://github.com/python/cpython.git
synced 2025-07-31 23:23:11 +00:00
Fix various minor errors in passing arguments to
PyArg_ParseTuple.
This commit is contained in:
parent
aac1316222
commit
a811c38d8e
4 changed files with 27 additions and 16 deletions
|
@ -1247,11 +1247,11 @@ static PyObject *py_dl_open(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
static PyObject *py_dl_close(PyObject *self, PyObject *args)
|
static PyObject *py_dl_close(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
void * handle;
|
int handle;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "i:dlclose", &handle))
|
if (!PyArg_ParseTuple(args, "i:dlclose", &handle))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (dlclose(handle)) {
|
if (dlclose((void*)handle)) {
|
||||||
PyErr_SetString(PyExc_OSError,
|
PyErr_SetString(PyExc_OSError,
|
||||||
ctypes_dlerror());
|
ctypes_dlerror());
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1263,12 +1263,12 @@ static PyObject *py_dl_close(PyObject *self, PyObject *args)
|
||||||
static PyObject *py_dl_sym(PyObject *self, PyObject *args)
|
static PyObject *py_dl_sym(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
void *handle;
|
int handle;
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "is:dlsym", &handle, &name))
|
if (!PyArg_ParseTuple(args, "is:dlsym", &handle, &name))
|
||||||
return NULL;
|
return NULL;
|
||||||
ptr = ctypes_dlsym(handle, name);
|
ptr = ctypes_dlsym((void*)handle, name);
|
||||||
if (!ptr) {
|
if (!ptr) {
|
||||||
PyErr_SetString(PyExc_OSError,
|
PyErr_SetString(PyExc_OSError,
|
||||||
ctypes_dlerror());
|
ctypes_dlerror());
|
||||||
|
@ -1286,7 +1286,7 @@ static PyObject *py_dl_sym(PyObject *self, PyObject *args)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
call_function(PyObject *self, PyObject *args)
|
call_function(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PPROC func;
|
int func;
|
||||||
PyObject *arguments;
|
PyObject *arguments;
|
||||||
PyObject *result;
|
PyObject *result;
|
||||||
|
|
||||||
|
@ -1296,7 +1296,7 @@ call_function(PyObject *self, PyObject *args)
|
||||||
&PyTuple_Type, &arguments))
|
&PyTuple_Type, &arguments))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
result = _CallProc(func,
|
result = _CallProc((PPROC)func,
|
||||||
arguments,
|
arguments,
|
||||||
#ifdef MS_WIN32
|
#ifdef MS_WIN32
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -1317,7 +1317,7 @@ call_function(PyObject *self, PyObject *args)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
call_cdeclfunction(PyObject *self, PyObject *args)
|
call_cdeclfunction(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PPROC func;
|
int func;
|
||||||
PyObject *arguments;
|
PyObject *arguments;
|
||||||
PyObject *result;
|
PyObject *result;
|
||||||
|
|
||||||
|
@ -1327,7 +1327,7 @@ call_cdeclfunction(PyObject *self, PyObject *args)
|
||||||
&PyTuple_Type, &arguments))
|
&PyTuple_Type, &arguments))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
result = _CallProc(func,
|
result = _CallProc((PPROC)func,
|
||||||
arguments,
|
arguments,
|
||||||
#ifdef MS_WIN32
|
#ifdef MS_WIN32
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -1510,7 +1510,7 @@ resize(PyObject *self, PyObject *args)
|
||||||
#else
|
#else
|
||||||
"On:resize",
|
"On:resize",
|
||||||
#endif
|
#endif
|
||||||
(PyObject *)&obj, &size))
|
&obj, &size))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
dict = PyObject_stgdict((PyObject *)obj);
|
dict = PyObject_stgdict((PyObject *)obj);
|
||||||
|
|
|
@ -317,7 +317,7 @@ PySocket_ssl(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O!|zz:ssl",
|
if (!PyArg_ParseTuple(args, "O!|zz:ssl",
|
||||||
PySocketModule.Sock_Type,
|
PySocketModule.Sock_Type,
|
||||||
(PyObject*)&Sock,
|
&Sock,
|
||||||
&key_file, &cert_file))
|
&key_file, &cert_file))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
|
@ -472,8 +472,12 @@ audioop_findfit(PyObject *self, PyObject *args)
|
||||||
double aj_m1, aj_lm1;
|
double aj_m1, aj_lm1;
|
||||||
double sum_ri_2, sum_aij_2, sum_aij_ri, result, best_result, factor;
|
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",
|
if ( !PyArg_ParseTuple(args, "s#s#:findfit",
|
||||||
&cp1, &len1, &cp2, &len2) )
|
(char**)&cp1, &len1, (char**)&cp2, &len2) )
|
||||||
return 0;
|
return 0;
|
||||||
if ( len1 & 1 || len2 & 1 ) {
|
if ( len1 & 1 || len2 & 1 ) {
|
||||||
PyErr_SetString(AudioopError, "Strings should be even-sized");
|
PyErr_SetString(AudioopError, "Strings should be even-sized");
|
||||||
|
@ -530,7 +534,7 @@ audioop_findfactor(PyObject *self, PyObject *args)
|
||||||
double sum_ri_2, sum_aij_ri, result;
|
double sum_ri_2, sum_aij_ri, result;
|
||||||
|
|
||||||
if ( !PyArg_ParseTuple(args, "s#s#:findfactor",
|
if ( !PyArg_ParseTuple(args, "s#s#:findfactor",
|
||||||
&cp1, &len1, &cp2, &len2) )
|
(char**)&cp1, &len1, (char**)&cp2, &len2) )
|
||||||
return 0;
|
return 0;
|
||||||
if ( len1 & 1 || len2 & 1 ) {
|
if ( len1 & 1 || len2 & 1 ) {
|
||||||
PyErr_SetString(AudioopError, "Strings should be even-sized");
|
PyErr_SetString(AudioopError, "Strings should be even-sized");
|
||||||
|
@ -562,7 +566,8 @@ audioop_findmax(PyObject *self, PyObject *args)
|
||||||
double aj_m1, aj_lm1;
|
double aj_m1, aj_lm1;
|
||||||
double result, best_result;
|
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;
|
return 0;
|
||||||
if ( len1 & 1 ) {
|
if ( len1 & 1 ) {
|
||||||
PyErr_SetString(AudioopError, "Strings should be even-sized");
|
PyErr_SetString(AudioopError, "Strings should be even-sized");
|
||||||
|
|
|
@ -208,11 +208,13 @@ dbm_keys(register dbmobject *dp, PyObject *unused)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
dbm_has_key(register dbmobject *dp, PyObject *args)
|
dbm_has_key(register dbmobject *dp, PyObject *args)
|
||||||
{
|
{
|
||||||
|
char *tmp_ptr;
|
||||||
datum key, val;
|
datum key, val;
|
||||||
int tmp_size;
|
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;
|
return NULL;
|
||||||
|
key.dptr = tmp_ptr;
|
||||||
key.dsize = tmp_size;
|
key.dsize = tmp_size;
|
||||||
check_dbmobject_open(dp);
|
check_dbmobject_open(dp);
|
||||||
val = dbm_fetch(dp->di_dbm, key);
|
val = dbm_fetch(dp->di_dbm, key);
|
||||||
|
@ -224,11 +226,13 @@ dbm_get(register dbmobject *dp, PyObject *args)
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
PyObject *defvalue = Py_None;
|
PyObject *defvalue = Py_None;
|
||||||
|
char *tmp_ptr;
|
||||||
int tmp_size;
|
int tmp_size;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "s#|O:get",
|
if (!PyArg_ParseTuple(args, "s#|O:get",
|
||||||
&key.dptr, &tmp_size, &defvalue))
|
&tmp_ptr, &tmp_size, &defvalue))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
key.dptr = tmp_ptr;
|
||||||
key.dsize = tmp_size;
|
key.dsize = tmp_size;
|
||||||
check_dbmobject_open(dp);
|
check_dbmobject_open(dp);
|
||||||
val = dbm_fetch(dp->di_dbm, key);
|
val = dbm_fetch(dp->di_dbm, key);
|
||||||
|
@ -245,11 +249,13 @@ dbm_setdefault(register dbmobject *dp, PyObject *args)
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
PyObject *defvalue = NULL;
|
PyObject *defvalue = NULL;
|
||||||
|
char *tmp_ptr;
|
||||||
int tmp_size;
|
int tmp_size;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "s#|S:setdefault",
|
if (!PyArg_ParseTuple(args, "s#|S:setdefault",
|
||||||
&key.dptr, &tmp_size, &defvalue))
|
&tmp_ptr, &tmp_size, &defvalue))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
key.dptr = tmp_ptr;
|
||||||
key.dsize = tmp_size;
|
key.dsize = tmp_size;
|
||||||
check_dbmobject_open(dp);
|
check_dbmobject_open(dp);
|
||||||
val = dbm_fetch(dp->di_dbm, key);
|
val = dbm_fetch(dp->di_dbm, key);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue