From af7e82de79568881a4cc23f62a251473d4755d0d Mon Sep 17 00:00:00 2001 From: Milan-CSE Date: Wed, 21 Oct 2026 23:30:08 +0530 Subject: [PATCH 1/2] gh-160035: Simplify datetime awareness docs --- Doc/library/datetime.rst | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index af904a05a47f06..92d4512df4c7c8 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -180,19 +180,11 @@ Objects of the :class:`date` type are always naive. An object of type :class:`.time` or :class:`.datetime` may be aware or naive. -A :class:`.datetime` object ``d`` is aware if both of the following hold: +A :class:`.datetime` object ``d`` is aware if ``d.utcoffset()`` does not return +``None``. Otherwise, ``d`` is naive. -1. ``d.tzinfo`` is not ``None`` -2. ``d.tzinfo.utcoffset(d)`` does not return ``None`` - -Otherwise, ``d`` is naive. - -A :class:`.time` object ``t`` is aware if both of the following hold: - -1. ``t.tzinfo`` is not ``None`` -2. ``t.tzinfo.utcoffset(None)`` does not return ``None``. - -Otherwise, ``t`` is naive. +A :class:`.time` object ``t`` is aware if ``t.utcoffset()`` does not return +``None``. Otherwise, ``t`` is naive. The distinction between aware and naive doesn't apply to :class:`timedelta` objects. From 1257cded4942074841380d705d76e374b79044ae Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Thu, 22 Oct 2026 07:40:54 +0100 Subject: [PATCH 2/2] Add references --- Doc/library/datetime.rst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index 92d4512df4c7c8..2598ab40b23da7 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -180,11 +180,13 @@ Objects of the :class:`date` type are always naive. An object of type :class:`.time` or :class:`.datetime` may be aware or naive. -A :class:`.datetime` object ``d`` is aware if ``d.utcoffset()`` does not return -``None``. Otherwise, ``d`` is naive. +A :class:`.datetime` object ``d`` is aware if +:meth:`d.utcoffset() ` does not return ``None``. +Otherwise, ``d`` is naive. -A :class:`.time` object ``t`` is aware if ``t.utcoffset()`` does not return -``None``. Otherwise, ``t`` is naive. +A :class:`.time` object ``t`` is aware if +:meth:`t.utcoffset() ` does not return ``None``. +Otherwise, ``t`` is naive. The distinction between aware and naive doesn't apply to :class:`timedelta` objects.