case 'b': { /* unsigned byte -- very short int */
char *p = va_arg(*p_va, char *);
- long ival = PyInt_AsLong(arg);
+ long ival;
+ if (PyFloat_Check(arg))
+ return converterr("integer", arg, msgbuf, bufsize);
+ ival = PyInt_AsLong(arg);
if (ival == -1 && PyErr_Occurred())
return converterr("integer<b>", arg, msgbuf, bufsize);
else if (ival < 0) {
case 'B': {/* byte sized bitfield - both signed and unsigned
values allowed */
char *p = va_arg(*p_va, char *);
- long ival = PyInt_AsLong(arg);
+ long ival;
+ if (PyFloat_Check(arg))
+ return converterr("integer", arg, msgbuf, bufsize);
+ ival = PyInt_AsLong(arg);
if (ival == -1 && PyErr_Occurred())
return converterr("integer<b>", arg, msgbuf, bufsize);
else if (ival < SCHAR_MIN) {
case 'h': {/* signed short int */
short *p = va_arg(*p_va, short *);
- long ival = PyInt_AsLong(arg);
+ long ival;
+ if (PyFloat_Check(arg))
+ return converterr("integer", arg, msgbuf, bufsize);
+ ival = PyInt_AsLong(arg);
if (ival == -1 && PyErr_Occurred())
return converterr("integer<h>", arg, msgbuf, bufsize);
else if (ival < SHRT_MIN) {
case 'H': { /* short int sized bitfield, both signed and
unsigned allowed */
unsigned short *p = va_arg(*p_va, unsigned short *);
- long ival = PyInt_AsLong(arg);
+ long ival;
+ if (PyFloat_Check(arg))
+ return converterr("integer", arg, msgbuf, bufsize);
+ ival = PyInt_AsLong(arg);
if (ival == -1 && PyErr_Occurred())
return converterr("integer<H>", arg, msgbuf, bufsize);
else if (ival < SHRT_MIN) {
case 'i': {/* signed int */
int *p = va_arg(*p_va, int *);
- long ival = PyInt_AsLong(arg);
+ long ival;
+ if (PyFloat_Check(arg))
+ return converterr("integer", arg, msgbuf, bufsize);
+ ival = PyInt_AsLong(arg);
if (ival == -1 && PyErr_Occurred())
return converterr("integer<i>", arg, msgbuf, bufsize);
else if (ival > INT_MAX) {
case 'l': {/* long int */
long *p = va_arg(*p_va, long *);
- long ival = PyInt_AsLong(arg);
+ long ival;
+ if (PyFloat_Check(arg))
+ return converterr("integer", arg, msgbuf, bufsize);
+ ival = PyInt_AsLong(arg);
if (ival == -1 && PyErr_Occurred())
return converterr("integer<l>", arg, msgbuf, bufsize);
else