Author WarrenWeckesser
Recipients WarrenWeckesser
Date 2019-10-06.02:40:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1570329620.36.0.696849357019.issue38382@roundup.psfhosted.org>
In-reply-to
Content
The premature return on ZeroDivisionError also causes an inconsistency in how types are handled.  For example,

>>> harmonic_mean([1, 0, "foo"])
0

We get an error as expected if "foo" occurs before 0:

>>> harmonic_mean([1, "foo", 0])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/warren/repos/git/forks/cpython/Lib/statistics.py", line 406, in harmonic_mean
    T, total, count = _sum(1/x for x in _fail_neg(data, errmsg))
  File "/Users/warren/repos/git/forks/cpython/Lib/statistics.py", line 166, in _sum
    for n,d in map(_exact_ratio, values):
  File "/Users/warren/repos/git/forks/cpython/Lib/statistics.py", line 406, in <genexpr>
    T, total, count = _sum(1/x for x in _fail_neg(data, errmsg))
  File "/Users/warren/repos/git/forks/cpython/Lib/statistics.py", line 288, in _fail_neg
    if x < 0:
TypeError: '<' not supported between instances of 'str' and 'int'
History
Date User Action Args
2019-10-06 02:40:20WarrenWeckessersetrecipients: + WarrenWeckesser
2019-10-06 02:40:20WarrenWeckessersetmessageid: <1570329620.36.0.696849357019.issue38382@roundup.psfhosted.org>
2019-10-06 02:40:20WarrenWeckesserlinkissue38382 messages
2019-10-06 02:40:20WarrenWeckessercreate