summaryrefslogtreecommitdiff
path: root/Lib/statistics.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2014-02-08 19:44:16 +1000
committerNick Coghlan <ncoghlan@gmail.com>2014-02-08 19:44:16 +1000
commitbfd68bf4ac6661bf0fab51178583bee88840a8e6 (patch)
tree25150831444976e4c64ac363fee3645861612d90 /Lib/statistics.py
parentec1c8097c18c5fadaf74ff25c9bc88bf661e3222 (diff)
downloadcpython-git-bfd68bf4ac6661bf0fab51178583bee88840a8e6.tar.gz
Issue #20478: avoid special casing Counter in statistics
Passing Counter objects to the Counter constructor is special cased, going through iter() firsts ensures they are handled the same way as any other iterable. (Committing on Steven's behalf as I don't believe his SSH key is registered yet)
Diffstat (limited to 'Lib/statistics.py')
-rw-r--r--Lib/statistics.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/Lib/statistics.py b/Lib/statistics.py
index a67a6d11cd..9359ed71e5 100644
--- a/Lib/statistics.py
+++ b/Lib/statistics.py
@@ -268,9 +268,7 @@ def _coerce_types(T1, T2):
def _counts(data):
# Generate a table of sorted (value, frequency) pairs.
- if data is None:
- raise TypeError('None is not iterable')
- table = collections.Counter(data).most_common()
+ table = collections.Counter(iter(data)).most_common()
if not table:
return table
# Extract the values with the highest frequency.