diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2014-02-08 09:44:16 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2014-02-08 09:44:16 (GMT) |
commit | bfd68bf4ac6661bf0fab51178583bee88840a8e6 (patch) | |
tree | 25150831444976e4c64ac363fee3645861612d90 /Lib/statistics.py | |
parent | ec1c8097c18c5fadaf74ff25c9bc88bf661e3222 (diff) | |
download | cpython-bfd68bf4ac6661bf0fab51178583bee88840a8e6.zip cpython-bfd68bf4ac6661bf0fab51178583bee88840a8e6.tar.gz cpython-bfd68bf4ac6661bf0fab51178583bee88840a8e6.tar.bz2 |
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.py | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/Lib/statistics.py b/Lib/statistics.py index a67a6d1..9359ed7 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. |