[issue35364] Datetime “fromtimestamp()” ignores inheritance if timezone is not None

Serhiy Storchaka report at bugs.python.org
Tue Dec 4 11:04:28 EST 2018


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

This is not easy problem, ant it doesn't have right solution. Different decisions were made for the result type of alternate constructors and operators for different classes.
 
The frombytes() method of an int subclass returns an int. As well arithmetic operations with int subclasses return an int.

The fromhex() method of a bytes subclass returns an instance of this subclass. But arithmetic operations with bytes subclasses return a bytes object.

The fromkeys() method of a dict subclass returns an instance of this subclass. The copy() method of a dict subclass returns a dict. The copy() method of a dict subclass returns a dict. But defaultdict, OrdertedDict and Counter redefine it: copy() methods of their subclasses return the object of the same type.

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35364>
_______________________________________


More information about the Python-bugs-list mailing list