Kaydet (Commit) fbbb9bde authored tarafından Mark Dickinson's avatar Mark Dickinson

Merged revisions 77275 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r77275 | mark.dickinson | 2010-01-03 12:03:03 +0000 (Sun, 03 Jan 2010) | 1 line

  Make use of PyLong_AsLongAndOverflow in math_ldexp.
........
üst 479def3f
...@@ -1251,28 +1251,18 @@ math_ldexp(PyObject *self, PyObject *args) ...@@ -1251,28 +1251,18 @@ math_ldexp(PyObject *self, PyObject *args)
double x, r; double x, r;
PyObject *oexp; PyObject *oexp;
long exp; long exp;
int overflow;
if (! PyArg_ParseTuple(args, "dO:ldexp", &x, &oexp)) if (! PyArg_ParseTuple(args, "dO:ldexp", &x, &oexp))
return NULL; return NULL;
if (PyLong_Check(oexp)) { if (PyLong_Check(oexp)) {
/* on overflow, replace exponent with either LONG_MAX /* on overflow, replace exponent with either LONG_MAX
or LONG_MIN, depending on the sign. */ or LONG_MIN, depending on the sign. */
exp = PyLong_AsLong(oexp); exp = PyLong_AsLongAndOverflow(oexp, &overflow);
if (exp == -1 && PyErr_Occurred()) { if (exp == -1 && PyErr_Occurred())
if (PyErr_ExceptionMatches(PyExc_OverflowError)) { return NULL;
if (Py_SIZE(oexp) < 0) { if (overflow)
exp = LONG_MIN; exp = overflow < 0 ? LONG_MIN : LONG_MAX;
}
else {
exp = LONG_MAX;
}
PyErr_Clear();
}
else {
/* propagate any unexpected exception */
return NULL;
}
}
} }
else { else {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
......
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