Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue37579

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:Difference in equality check between C and Python implementation for datetime module's timedelta and time
Type:behaviorStage:resolved
Components:Library (Lib)Versions:Python 3.9, Python 3.8, Python 3.7
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: belopolsky, miss-islington, p-ganssle, serhiy.storchaka, xtreak
Priority:normalKeywords:patch

Created on2019-07-13 05:25 byxtreak, last changed2022-04-11 14:59 byadmin. This issue is nowclosed.

Pull Requests
URLStatusLinkedEdit
PR 14726mergedxtreak,2019-07-13 05:36
PR 14743mergedmiss-islington,2019-07-13 13:37
PR 14745mergedxtreak,2019-07-13 13:43
Messages (6)
msg347773 -(view)Author: Karthikeyan Singaravelan (xtreak)*(Python committer)Date: 2019-07-13 05:25
As reported by Serhiy onhttps://bugs.python.org/issue37555#msg347733 there is a difference in __eq__ definition in datetime module's C and Python implementation for timedelta and time. When the other in __eq__ is not of the same type NotImplemented is not returned in Python implementation like C causing equality to behave differently.Difference in C implementation and Python implementation for datetime.timedelta.__eq__https://github.com/python/cpython/blob/c8e7146de257930ea8d0d4aa74b3a64fcaa79d4b/Modules/_datetimemodule.c#L2152static PyObject *delta_richcompare(PyObject *self, PyObject *other, int op){    if (PyDelta_Check(other)) {        int diff = delta_cmp(self, other);        return diff_to_bool(diff, op);    }    else {        Py_RETURN_NOTIMPLEMENTED;    }}https://github.com/python/cpython/blob/c8e7146de257930ea8d0d4aa74b3a64fcaa79d4b/Lib/datetime.py#L732def __eq__(self, other):    if isinstance(other, timedelta):        return self._cmp(other) == 0    else:        return FalseI will add a PR for this with test.
msg347813 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2019-07-13 13:15
Do you mind to fix also other similar cases if they are? __lt__ and others should have the same property.
msg347815 -(view)Author: Paul Ganssle (p-ganssle)*(Python committer)Date: 2019-07-13 13:22
New changesete6b46aafad3427463d6264a68824df4797e682f1 by Paul Ganssle (Xtreak) in branch 'master':bpo-37579: Improve equality behavior for pure Python datetime and time (GH-14726)https://github.com/python/cpython/commit/e6b46aafad3427463d6264a68824df4797e682f1
msg347821 -(view)Author: miss-islington (miss-islington)Date: 2019-07-13 13:59
New changeset143672cf028740fc549e532c049559c522930c95 by Miss Islington (bot) in branch '3.8':bpo-37579: Improve equality behavior for pure Python datetime and time (GH-14726)https://github.com/python/cpython/commit/143672cf028740fc549e532c049559c522930c95
msg347903 -(view)Author: miss-islington (miss-islington)Date: 2019-07-14 10:14
New changesetc6b31061997526b31961ec34328408ca421f51fc by Miss Islington (bot) (Xtreak) in branch '3.7':[3.7]bpo-37579: Improve equality behavior for pure Python datetime and time (GH-14726) (GH-14745)https://github.com/python/cpython/commit/c6b31061997526b31961ec34328408ca421f51fc
msg348454 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2019-07-25 21:16
Seeissue37685.
History
DateUserActionArgs
2022-04-11 14:59:18adminsetgithub: 81760
2019-07-25 21:16:37serhiy.storchakasetmessages: +msg348454
2019-07-14 10:14:03miss-islingtonsetmessages: +msg347903
2019-07-14 10:04:38p-gansslesetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-07-13 13:59:40miss-islingtonsetnosy: +miss-islington
messages: +msg347821
2019-07-13 13:43:16xtreaksetpull_requests: +pull_request14541
2019-07-13 13:37:44miss-islingtonsetpull_requests: +pull_request14539
2019-07-13 13:22:25p-gansslesetmessages: +msg347815
2019-07-13 13:15:52serhiy.storchakasetmessages: +msg347813
2019-07-13 05:36:56xtreaksetkeywords: +patch
stage: patch review
pull_requests: +pull_request14522
2019-07-13 05:25:41xtreakcreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp