diff -r 7e179ee91af0 Lib/statistics.py --- a/Lib/statistics.py Mon Mar 23 15:26:49 2015 +0200 +++ b/Lib/statistics.py Sat May 02 21:49:05 2015 +0200 @@ -176,6 +176,10 @@ total = Fraction() for d, n in sorted(partials.items()): total += Fraction(n, d) + if T is int or T is bool: + assert type(total.numerator) is int + assert total.denominator == 1 + return total.numerator if issubclass(T, int): assert total.denominator == 1 return T(total.numerator)