@@ -10,19 +10,6 @@ PyInt_GetMax(void)
1010 return LONG_MAX ; /* To initialize sys.maxint */
1111}
1212
13- /* Return 1 if exception raised, 0 if caller should retry using longs */
14- static int
15- err_ovf (char * msg )
16- {
17- if (PyErr_Warn (PyExc_OverflowWarning , msg ) < 0 ) {
18- if (PyErr_ExceptionMatches (PyExc_OverflowWarning ))
19- PyErr_SetString (PyExc_OverflowError , msg );
20- return 1 ;
21- }
22- else
23- return 0 ;
24- }
25-
2613/* Integers are quite normal objects, to make object handling uniform.
2714 (Using odd pointers to represent integers would save much space
2815 but require extra checks for this special case throughout the code.)
@@ -306,11 +293,8 @@ PyInt_FromString(char *s, char **pend, int base)
306293 PyErr_SetString (PyExc_ValueError , buffer );
307294 return NULL ;
308295 }
309- else if (errno != 0 ) {
310- if (err_ovf ("string/unicode conversion" ))
311- return NULL ;
296+ else if (errno != 0 )
312297 return PyLong_FromString (s , pend , base );
313- }
314298 if (pend )
315299 * pend = end ;
316300 return PyInt_FromLong (x );
@@ -396,8 +380,6 @@ int_add(PyIntObject *v, PyIntObject *w)
396380 x = a + b ;
397381 if ((x ^a ) >= 0 || (x ^b ) >= 0 )
398382 return PyInt_FromLong (x );
399- if (err_ovf ("integer addition" ))
400- return NULL ;
401383 return PyLong_Type .tp_as_number -> nb_add ((PyObject * )v , (PyObject * )w );
402384}
403385
@@ -410,8 +392,6 @@ int_sub(PyIntObject *v, PyIntObject *w)
410392 x = a - b ;
411393 if ((x ^a ) >= 0 || (x ^~b ) >= 0 )
412394 return PyInt_FromLong (x );
413- if (err_ovf ("integer subtraction" ))
414- return NULL ;
415395 return PyLong_Type .tp_as_number -> nb_subtract ((PyObject * )v ,
416396 (PyObject * )w );
417397}
@@ -475,8 +455,6 @@ int_mul(PyObject *v, PyObject *w)
475455 32 * absdiff <= absprod -- 5 good bits is "close enough" */
476456 if (32.0 * absdiff <= absprod )
477457 return PyInt_FromLong (longprod );
478- else if (err_ovf ("integer multiplication" ))
479- return NULL ;
480458 else
481459 return PyLong_Type .tp_as_number -> nb_multiply (v , w );
482460 }
@@ -501,11 +479,8 @@ i_divmod(register long x, register long y,
501479 return DIVMOD_ERROR ;
502480 }
503481 /* (-sys.maxint-1)/-1 is the only overflow case. */
504- if (y == -1 && x < 0 && x == - x ) {
505- if (err_ovf ("integer division" ))
506- return DIVMOD_ERROR ;
482+ if (y == -1 && x < 0 && x == - x )
507483 return DIVMOD_OVERFLOW ;
508- }
509484 xdivy = x / y ;
510485 xmody = x - xdivy * y ;
511486 /* If the signs of x and y differ, and the remainder is non-0,
@@ -654,8 +629,6 @@ int_pow(PyIntObject *v, PyIntObject *w, PyIntObject *z)
654629 if (temp == 0 )
655630 break ; /* Avoid ix / 0 */
656631 if (ix / temp != prev ) {
657- if (err_ovf ("integer exponentiation" ))
658- return NULL ;
659632 return PyLong_Type .tp_as_number -> nb_power (
660633 (PyObject * )v ,
661634 (PyObject * )w ,
@@ -666,9 +639,7 @@ int_pow(PyIntObject *v, PyIntObject *w, PyIntObject *z)
666639 if (iw == 0 ) break ;
667640 prev = temp ;
668641 temp *= temp ; /* Square the value of temp */
669- if (prev != 0 && temp /prev != prev ) {
670- if (err_ovf ("integer exponentiation" ))
671- return NULL ;
642+ if (prev != 0 && temp / prev != prev ) {
672643 return PyLong_Type .tp_as_number -> nb_power (
673644 (PyObject * )v , (PyObject * )w , (PyObject * )z );
674645 }
@@ -701,10 +672,7 @@ int_neg(PyIntObject *v)
701672 a = v -> ob_ival ;
702673 x = - a ;
703674 if (a < 0 && x < 0 ) {
704- PyObject * o ;
705- if (err_ovf ("integer negation" ))
706- return NULL ;
707- o = PyLong_FromLong (a );
675+ PyObject * o = PyLong_FromLong (a );
708676 if (o != NULL ) {
709677 PyObject * result = PyNumber_Negative (o );
710678 Py_DECREF (o );
0 commit comments