Kaydet (Commit) 5e08cb8e authored tarafından Guido van Rossum's avatar Guido van Rossum

Vladimir Marangozov:

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. Swapping the two checks in the signed int code makes the problem
go away.

Also, make the error messages fit in 80 char lines in the
source.
üst d7823f26
...@@ -473,12 +473,12 @@ convertsimple1(arg, p_format, p_va) ...@@ -473,12 +473,12 @@ convertsimple1(arg, p_format, p_va)
return "integer<b>"; return "integer<b>";
else if (ival < 0) { else if (ival < 0) {
PyErr_SetString(PyExc_OverflowError, PyErr_SetString(PyExc_OverflowError,
"unsigned byte integer is less than minimum"); "unsigned byte integer is less than minimum");
return "integer<b>"; return "integer<b>";
} }
else if (ival > UCHAR_MAX) { else if (ival > UCHAR_MAX) {
PyErr_SetString(PyExc_OverflowError, PyErr_SetString(PyExc_OverflowError,
"unsigned byte integer is greater than maximum"); "unsigned byte integer is greater than maximum");
return "integer<b>"; return "integer<b>";
} }
else else
...@@ -494,12 +494,12 @@ convertsimple1(arg, p_format, p_va) ...@@ -494,12 +494,12 @@ convertsimple1(arg, p_format, p_va)
return "integer<h>"; return "integer<h>";
else if (ival < SHRT_MIN) { else if (ival < SHRT_MIN) {
PyErr_SetString(PyExc_OverflowError, PyErr_SetString(PyExc_OverflowError,
"signed short integer is less than minimum"); "signed short integer is less than minimum");
return "integer<h>"; return "integer<h>";
} }
else if (ival > SHRT_MAX) { else if (ival > SHRT_MAX) {
PyErr_SetString(PyExc_OverflowError, PyErr_SetString(PyExc_OverflowError,
"signed short integer is greater than maximum"); "signed short integer is greater than maximum");
return "integer<h>"; return "integer<h>";
} }
else else
...@@ -513,14 +513,14 @@ convertsimple1(arg, p_format, p_va) ...@@ -513,14 +513,14 @@ convertsimple1(arg, p_format, p_va)
long ival = PyInt_AsLong(arg); long ival = PyInt_AsLong(arg);
if (ival == -1 && PyErr_Occurred()) if (ival == -1 && PyErr_Occurred())
return "integer<i>"; return "integer<i>";
else if (ival < INT_MIN) { else if (ival > INT_MAX) {
PyErr_SetString(PyExc_OverflowError, PyErr_SetString(PyExc_OverflowError,
"signed integer is less than minimum"); "signed integer is greater than maximum");
return "integer<i>"; return "integer<i>";
} }
else if (ival > INT_MAX) { else if (ival < INT_MIN) {
PyErr_SetString(PyExc_OverflowError, PyErr_SetString(PyExc_OverflowError,
"signed integer is greater than maximum"); "signed integer is less than minimum");
return "integer<i>"; return "integer<i>";
} }
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment