Eugene Toder added the comment:

There's a similar issue with replace() methods on date/time/datetime classes. 
They create instances of derived types without calling derived 
__new__/__init__, thus potentially leaving those uninitialized.

>>> from datetime import date
>>> class D(date):
...   def __init__(self, y, m, d):
...     self.y = y
>>> D(2016,1,1).y
2016
>>> D(2016,1,1).replace(2015).y
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'D' object has no attribute 'y'

----------
nosy: +eltoder

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

Reply via email to