Fix OrderedSet `__repr__` protocol for non-string objects
Prefer using `repr` on the keys to `str` since `repr` is guaranteed to
be implemented, and will return something "good enough"
@@ -708,7 +708,8 @@ class OrderedSet(collections.MutableSet):
def __repr__(self):
# Don't print 'OrderedSet("")' for an empty set.
if self.__container:
- return 'OrderedSet("{}")'.format('", "'.join(self.__container.keys()))
+ return 'OrderedSet("{}")'.format(
+ '", "'.join(repr(e) for e in self.__container.keys()))
return 'OrderedSet()'
def add(self, value):
