@@ -342,7 +342,7 @@ int_mul(v, w)
342342 b = - b ;
343343 if (b < 0 ) {
344344 /* Largest negative */
345- if (a == 0 || a == 1 && s == 1 ) {
345+ if (a == 0 || ( a == 1 && s == 1 ) ) {
346346 x = a * b ;
347347 goto ok ;
348348 }
@@ -427,7 +427,7 @@ i_divmod(x, y, p_xdivy, p_xmody)
427427 xdivy = xi / yi ;
428428 }
429429 xmody = xi - xdivy * yi ;
430- if (xmody < 0 && yi > 0 || xmody > 0 && yi < 0 ) {
430+ if (( xmody < 0 && yi > 0 ) || ( xmody > 0 && yi < 0 ) ) {
431431 xmody += yi ;
432432 xdivy -= 1 ;
433433 }
@@ -476,8 +476,7 @@ int_pow(v, w, z)
476476 intobject * z ;
477477{
478478#if 1
479- register long iv , iw , iz , ix , temp , prev ;
480- int zset = 0 ;
479+ register long iv , iw , iz = 0 , ix , temp , prev ;
481480 iv = v -> ob_ival ;
482481 iw = w -> ob_ival ;
483482 if (iw < 0 ) {
@@ -486,7 +485,10 @@ int_pow(v, w, z)
486485 }
487486 if ((object * )z != None ) {
488487 iz = z -> ob_ival ;
489- zset = 1 ;
488+ if (iz == 0 ) {
489+ err_setstr (ValueError , "pow(x, y, z) with z==0" );
490+ return NULL ;
491+ }
490492 }
491493 /*
492494 * XXX: The original exponentiation code stopped looping
@@ -513,13 +515,13 @@ int_pow(v, w, z)
513515 temp *= temp ; /* Square the value of temp */
514516 if (prev != 0 && temp /prev != prev )
515517 return err_ovf ("integer pow()" );
516- if (zset ) {
518+ if (iz ) {
517519 /* If we did a multiplication, perform a modulo */
518520 ix = ix % iz ;
519521 temp = temp % iz ;
520522 }
521523 }
522- if (zset ) {
524+ if (iz ) {
523525 object * t1 , * t2 ;
524526 long int div , mod ;
525527 t1 = newintobject (ix );
0 commit comments