Olivier Gagnon added the comment:

The dictionary and the set do not give the freedom to add dynamic attributes to 
them. I agree that the Counter should have the same behaviour.

However, this will raise the same bug when we inherit from a Counter object.

>>> class mylist(list): pass
... 
>>> l = mylist()
>>> l.foo = "bar"
>>> c = copy.deepcopy(l)
>>> print(c.foo) # prints bar

>>> class myCounter(Counter): pass
... 
>>> original = myCounter()
>>> original.foo = "bar"
>>> c = copy.deepcopy(original)
>>> c.foo
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'myCounter' object has no attribute 'foo'

The reduction function should still copy every dynamic attribute of the object.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18352>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to