[Patches] getargs.c

Vladimir Marangozov Vladimir.Marangozov@inrialpes.fr
Sun, 18 Jun 2000 00:26:29 +0200 (CEST)


This patch fixes a problem on AIX with the signed int case code in getargs.c,
after Trent Mick's intervention about MIN/MAX overflow checks.  The AIX
compiler/optimizer generates bogus code with the default flags "-g -O"
causing test_builtin to fail: int("10", 16) <> 16L.  Hopefully, swapping
the two checks in the signed int code makes the problem go away.

Also, make the error messages fit in 80 char lines.

-- 
       Vladimir MARANGOZOV          | Vladimir.Marangozov@inrialpes.fr
http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252

--

Disclaimer:

I confirm that, to the best of my knowledge and belief, this contribution is
free of any claims of third parties under copyright, patent or other rights
or interests ("claims").  To the extent that I have any such claims, I
hereby grant to CNRI a nonexclusive, irrevocable, royalty-free, worldwide
license to reproduce, distribute, perform and/or display publicly, prepare
derivative versions, and otherwise use this contribution as part of the
Python software and its related documentation, or any derivative versions
thereof, at no cost to CNRI or its licensed users, and to authorize others
to do so.

I acknowledge that CNRI may, at its sole discretion, decide whether or not
to incorporate this contribution in the Python software and its related
documentation.  I further grant CNRI permission to use my name and other
identifying information provided to CNRI by me for use in connection with
the Python software and its related documentation.

-------------------------------[ cut here ]---------------------------
*** getargs.c-orig	Sat Jun 17 23:12:18 2000
--- getargs.c	Sat Jun 17 23:59:07 2000
***************
*** 473,484 ****
  				return "integer<b>";
  			else if (ival < 0) {
  				PyErr_SetString(PyExc_OverflowError,
! 					"unsigned byte integer is less than minimum");
  				return "integer<b>";
  			}
  			else if (ival > UCHAR_MAX) {
  				PyErr_SetString(PyExc_OverflowError,
! 				    "unsigned byte integer is greater than maximum");
  				return "integer<b>";
  			}
  			else
--- 473,484 ----
  				return "integer<b>";
  			else if (ival < 0) {
  				PyErr_SetString(PyExc_OverflowError,
! 			      "unsigned byte integer is less than minimum");
  				return "integer<b>";
  			}
  			else if (ival > UCHAR_MAX) {
  				PyErr_SetString(PyExc_OverflowError,
! 			      "unsigned byte integer is greater than maximum");
  				return "integer<b>";
  			}
  			else
***************
*** 494,505 ****
  				return "integer<h>";
  			else if (ival < SHRT_MIN) {
  				PyErr_SetString(PyExc_OverflowError,
! 					"signed short integer is less than minimum");
  				return "integer<h>";
  			}
  			else if (ival > SHRT_MAX) {
  				PyErr_SetString(PyExc_OverflowError,
! 				  "signed short integer is greater than maximum");
  				return "integer<h>";
  			}
  			else
--- 494,505 ----
  				return "integer<h>";
  			else if (ival < SHRT_MIN) {
  				PyErr_SetString(PyExc_OverflowError,
! 			      "signed short integer is less than minimum");
  				return "integer<h>";
  			}
  			else if (ival > SHRT_MAX) {
  				PyErr_SetString(PyExc_OverflowError,
! 			      "signed short integer is greater than maximum");
  				return "integer<h>";
  			}
  			else
***************
*** 513,526 ****
  			long ival = PyInt_AsLong(arg);
  			if (ival == -1 && PyErr_Occurred())
  				return "integer<i>";
! 			else if (ival < INT_MIN) {
  				PyErr_SetString(PyExc_OverflowError,
! 					"signed integer is less than minimum");
  				return "integer<i>";
  			}
! 			else if (ival > INT_MAX) {
  				PyErr_SetString(PyExc_OverflowError,
! 				  "signed integer is greater than maximum");
  				return "integer<i>";
  			}
  			else
--- 513,526 ----
  			long ival = PyInt_AsLong(arg);
  			if (ival == -1 && PyErr_Occurred())
  				return "integer<i>";
! 			else if (ival > INT_MAX) {
  				PyErr_SetString(PyExc_OverflowError,
! 				    "signed integer is greater than maximum");
  				return "integer<i>";
  			}
! 			else if (ival < INT_MIN) {
  				PyErr_SetString(PyExc_OverflowError,
! 				    "signed integer is less than minimum");
  				return "integer<i>";
  			}
  			else