Fix minor subclassing issue with collections.Counter

This commit is contained in:
Raymond Hettinger 2011-04-15 13:16:46 -07:00
parent 181810b5fe
commit 1c746c28f3
3 changed files with 13 additions and 2 deletions

View file

@ -459,8 +459,8 @@ def update(self, iterable=None, **kwds):
self.update(kwds)
def copy(self):
'Like dict.copy() but returns a Counter instance instead of a dict.'
return Counter(self)
'Return a shallow copy.'
return self.__class__(self)
def __reduce__(self):
return self.__class__, (dict(self),)