[issue34365] datetime's documentation refers to "comparison [...] falling back to the default scheme of comparing object addresses"
New submission from Kevin Norris <nykevin.norris@gmail.com>: The 3.x datetime documentation contains the following footnote:
In other words, date1 < date2 if and only if date1.toordinal() < date2.toordinal(). In order to stop comparison from falling back to the default scheme of comparing object addresses, date comparison normally raises TypeError if the other comparand isn’t also a date object. However, NotImplemented is returned instead if the other comparand has a timetuple() attribute. This hook gives other kinds of date objects a chance at implementing mixed-type comparison. If not, when a date object is compared to an object of a different type, TypeError is raised unless the comparison is == or !=. The latter cases return False or True, respectively.
But in 3.x, comparison no longer falls back to comparing object addresses. Also, some of the comments on issue 8005 seem to suggest that this footnote is not actually true in 3.x (aside from the first sentence, of course). But regardless, the footnote should not refer to a long dead interpreter behavior as if it were still around. ---------- assignee: docs@python components: Documentation messages: 323314 nosy: Kevin.Norris, docs@python priority: normal severity: normal status: open title: datetime's documentation refers to "comparison [...] falling back to the default scheme of comparing object addresses" versions: Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34365> _______________________________________
Change by Steve Dower <steve.dower@python.org>: ---------- keywords: +easy versions: -Python 3.4, Python 3.5 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34365> _______________________________________
Danish Prakash <grafitykoncept@gmail.com> added the comment:
But in 3.x, comparison no longer falls back to comparing object addresses.
What is the default fallback in 3.x? ---------- nosy: +prakashdanish _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34365> _______________________________________
Kevin Norris <nykevin.norris@gmail.com> added the comment: There is none. It raises a TypeError. See https://docs.python.org/3/reference/expressions.html#value-comparisons ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34365> _______________________________________
Change by Danish Prakash <grafitykoncept@gmail.com>: ---------- keywords: +patch pull_requests: +8292 stage: -> patch review _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34365> _______________________________________
Change by Paul Ganssle <p.ganssle@gmail.com>: ---------- nosy: +p-ganssle _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34365> _______________________________________
miss-islington <mariatta.wijaya+miss-islington@gmail.com> added the comment: New changeset 9c223794c754408644c16349b85dd27fdba8a926 by Miss Islington (bot) (Danish Prakash) in branch 'master': bpo-34365: Update date object documentation (GH-8814) https://github.com/python/cpython/commit/9c223794c754408644c16349b85dd27fdba... ---------- nosy: +miss-islington _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34365> _______________________________________
Change by miss-islington <mariatta.wijaya+miss-islington@gmail.com>: ---------- pull_requests: +8619 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34365> _______________________________________
Change by miss-islington <mariatta.wijaya+miss-islington@gmail.com>: ---------- pull_requests: +8620 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34365> _______________________________________
Mariatta Wijaya <mariatta.wijaya@gmail.com> added the comment: Thanks! ---------- nosy: +Mariatta resolution: -> fixed stage: patch review -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34365> _______________________________________
miss-islington <mariatta.wijaya+miss-islington@gmail.com> added the comment: New changeset e2b40f4ce954ea3d35a73541029b2253abd9d245 by Miss Islington (bot) in branch '3.7': bpo-34365: Update date object documentation (GH-8814) https://github.com/python/cpython/commit/e2b40f4ce954ea3d35a73541029b2253abd... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34365> _______________________________________
miss-islington <mariatta.wijaya+miss-islington@gmail.com> added the comment: New changeset 8a2c2d4e1b6b46a9a982e5c064ca4399ec28d55d by Miss Islington (bot) in branch '3.6': bpo-34365: Update date object documentation (GH-8814) https://github.com/python/cpython/commit/8a2c2d4e1b6b46a9a982e5c064ca4399ec2... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34365> _______________________________________
Change by Xtrem532 <Xtrem532.tg@gmail.com>: ---------- nosy: +Xtrem532 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34365> _______________________________________
participants (7)
-
Danish Prakash
-
Kevin Norris
-
Mariatta Wijaya
-
miss-islington
-
Paul Ganssle
-
Steve Dower
-
Xtrem532