Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3455338

Browse files
author
Michael W. Hudson
committed
Fix
[ 991812 ] PyArg_ParseTuple can miss errors with warnings as exceptions as suggested in the report. This is definitely a 2.3 candidate (as are most of the checkins I've made in the last month...)
1 parent fe80b63 commit 3455338

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

Python/getargs.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ convertsimple(PyObject *arg, char **p_format, va_list *p_va, char *msgbuf,
472472
char *p = va_arg(*p_va, char *);
473473
long ival;
474474
if (float_argument_error(arg))
475-
return NULL;
475+
return converterr("integer<b>", arg, msgbuf, bufsize);
476476
ival = PyInt_AsLong(arg);
477477
if (ival == -1 && PyErr_Occurred())
478478
return converterr("integer<b>", arg, msgbuf, bufsize);
@@ -496,7 +496,7 @@ convertsimple(PyObject *arg, char **p_format, va_list *p_va, char *msgbuf,
496496
char *p = va_arg(*p_va, char *);
497497
long ival;
498498
if (float_argument_error(arg))
499-
return NULL;
499+
return converterr("integer<B>", arg, msgbuf, bufsize);
500500
ival = PyInt_AsUnsignedLongMask(arg);
501501
if (ival == -1 && PyErr_Occurred())
502502
return converterr("integer<B>", arg, msgbuf, bufsize);
@@ -509,7 +509,7 @@ convertsimple(PyObject *arg, char **p_format, va_list *p_va, char *msgbuf,
509509
short *p = va_arg(*p_va, short *);
510510
long ival;
511511
if (float_argument_error(arg))
512-
return NULL;
512+
return converterr("integer<h>", arg, msgbuf, bufsize);
513513
ival = PyInt_AsLong(arg);
514514
if (ival == -1 && PyErr_Occurred())
515515
return converterr("integer<h>", arg, msgbuf, bufsize);
@@ -533,7 +533,7 @@ convertsimple(PyObject *arg, char **p_format, va_list *p_va, char *msgbuf,
533533
unsigned short *p = va_arg(*p_va, unsigned short *);
534534
long ival;
535535
if (float_argument_error(arg))
536-
return NULL;
536+
return converterr("integer<H>", arg, msgbuf, bufsize);
537537
ival = PyInt_AsUnsignedLongMask(arg);
538538
if (ival == -1 && PyErr_Occurred())
539539
return converterr("integer<H>", arg, msgbuf, bufsize);
@@ -546,7 +546,7 @@ convertsimple(PyObject *arg, char **p_format, va_list *p_va, char *msgbuf,
546546
int *p = va_arg(*p_va, int *);
547547
long ival;
548548
if (float_argument_error(arg))
549-
return NULL;
549+
return converterr("integer<i>", arg, msgbuf, bufsize);
550550
ival = PyInt_AsLong(arg);
551551
if (ival == -1 && PyErr_Occurred())
552552
return converterr("integer<i>", arg, msgbuf, bufsize);
@@ -570,7 +570,7 @@ convertsimple(PyObject *arg, char **p_format, va_list *p_va, char *msgbuf,
570570
unsigned int *p = va_arg(*p_va, unsigned int *);
571571
unsigned int ival;
572572
if (float_argument_error(arg))
573-
return NULL;
573+
return converterr("integer<I>", arg, msgbuf, bufsize);
574574
ival = PyInt_AsUnsignedLongMask(arg);
575575
if (ival == -1 && PyErr_Occurred())
576576
return converterr("integer<I>", arg, msgbuf, bufsize);
@@ -583,7 +583,7 @@ convertsimple(PyObject *arg, char **p_format, va_list *p_va, char *msgbuf,
583583
long *p = va_arg(*p_va, long *);
584584
long ival;
585585
if (float_argument_error(arg))
586-
return NULL;
586+
return converterr("integer<l>", arg, msgbuf, bufsize);
587587
ival = PyInt_AsLong(arg);
588588
if (ival == -1 && PyErr_Occurred())
589589
return converterr("integer<l>", arg, msgbuf, bufsize);
@@ -620,8 +620,6 @@ convertsimple(PyObject *arg, char **p_format, va_list *p_va, char *msgbuf,
620620
case 'K': { /* long long sized bitfield */
621621
unsigned PY_LONG_LONG *p = va_arg(*p_va, unsigned PY_LONG_LONG *);
622622
unsigned PY_LONG_LONG ival;
623-
if (float_argument_error(arg))
624-
return NULL;
625623
if (PyInt_Check(arg))
626624
ival = PyInt_AsUnsignedLongMask(arg);
627625
else if (PyLong_Check(arg))

0 commit comments

Comments
 (0)