[New-bugs-announce] [issue31222] datetime.py implementation of .replace inconsistent with C implementation
Paul G
report at bugs.python.org
Wed Aug 16 13:01:45 EDT 2017
New submission from Paul G:
In the .py implementation of datetime.replace (and date.replace and time.replace), the new datetime is created using the datetime type:
https://github.com/python/cpython/blob/master/Lib/datetime.py#L1578
But in the C source, it is created from type(self):
https://github.com/python/cpython/blob/master/Modules/_datetimemodule.c#L5046
I think the second should be the preferred behavior, so the datetime.py source should be updated to reflect that it's calling self.__class__(...) rather than datetime(...). I can prepare a PR if this would be desirable.
(That said, I'm not 100% clear under what circumstances the code in datetime.py is actually *used*, so I'm not sure how to write tests for it - is datetime.py essentially documentation, or is there a way to explicitly fall back to it?)
Per this issue on the pypy3 tracker:
https://bitbucket.org/pypy/pypy/issues/2635/datetimereplace-always-returns
----------
components: Interpreter Core
messages: 300377
nosy: p-ganssle
priority: normal
severity: normal
status: open
title: datetime.py implementation of .replace inconsistent with C implementation
versions: Python 3.5, Python 3.6, Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue31222>
_______________________________________
More information about the New-bugs-announce
mailing list