summaryrefslogtreecommitdiffstats
path: root/Lib/collections/__init__.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2011-11-05 20:39:57 (GMT)
committerRaymond Hettinger <python@rcn.com>2011-11-05 20:39:57 (GMT)
commitf1182cd4dbd2556c5cfeae24deb889e514979b18 (patch)
treecc24c4aa3ab4d8237d3ac78adcadf39ad2992823 /Lib/collections/__init__.py
parent748d7ae209f746979b03b9ab4534858221d8d3da (diff)
parent4e6bf41934de08f62b22b90cda2e331eb4641dea (diff)
downloadcpython-f1182cd4dbd2556c5cfeae24deb889e514979b18.zip
cpython-f1182cd4dbd2556c5cfeae24deb889e514979b18.tar.gz
cpython-f1182cd4dbd2556c5cfeae24deb889e514979b18.tar.bz2
Merge
Diffstat (limited to 'Lib/collections/__init__.py')
-rw-r--r--Lib/collections/__init__.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
index 68b63a8..6cae1dd 100644
--- a/Lib/collections/__init__.py
+++ b/Lib/collections/__init__.py
@@ -585,8 +585,12 @@ class Counter(dict):
def __repr__(self):
if not self:
return '%s()' % self.__class__.__name__
- items = ', '.join(map('%r: %r'.__mod__, self.most_common()))
- return '%s({%s})' % (self.__class__.__name__, items)
+ try:
+ items = ', '.join(map('%r: %r'.__mod__, self.most_common()))
+ return '%s({%s})' % (self.__class__.__name__, items)
+ except TypeError:
+ # handle case where values are not orderable
+ return '{0}({1!r})'.format(self.__class__.__name__, dict(self))
# Multiset-style mathematical operations discussed in:
# Knuth TAOCP Volume II section 4.6.3 exercise 19