def check_overflow(arg, ctype, fatal=True):
 maxval = MAXVALS[ctype]
 minval = MINVALS[ctype]
 if (arg > maxval):
  if fatal:
   raise OverflowError(arg)
  else:
   return maxval
 elif (arg < minval):
  if fatal:
   raise OverflowError(arg)
  else:
   return minval
 else:
  return arg

def check_overflow ( arg , ctype , fatal = True ) : maxval = MAXVALS [ ctype ] minval = MINVALS [ ctype ] if ( arg > maxval ) : if fatal : raise OverflowError ( arg ) else : return maxval elif ( arg < minval ) : if fatal : raise OverflowError ( arg ) else : return minval else : return arg
check if the given argument is in bounds for the given type .