[3.12] gh-106392: Fix inconsistency in deprecation warnings in datetime module (GH-114761) (#114767)

gh-106392: Fix inconsistency in deprecation warnings in datetime module (GH-114761)
(cherry picked from commit dc4cd2c9ba)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Islington (bot) 2024-01-31 04:24:27 +01:00 committed by GitHub
parent 4defc50100
commit 2e8417eec4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1805,7 +1805,7 @@ class datetime(date):
def utcfromtimestamp(cls, t):
"""Construct a naive UTC datetime from a POSIX timestamp."""
import warnings
warnings.warn("datetime.utcfromtimestamp() is deprecated and scheduled "
warnings.warn("datetime.datetime.utcfromtimestamp() is deprecated and scheduled "
"for removal in a future version. Use timezone-aware "
"objects to represent datetimes in UTC: "
"datetime.datetime.fromtimestamp(t, datetime.UTC).",
@ -1823,8 +1823,8 @@ class datetime(date):
def utcnow(cls):
"Construct a UTC datetime from time.time()."
import warnings
warnings.warn("datetime.utcnow() is deprecated and scheduled for "
"removal in a future version. Instead, Use timezone-aware "
warnings.warn("datetime.datetime.utcnow() is deprecated and scheduled for "
"removal in a future version. Use timezone-aware "
"objects to represent datetimes in UTC: "
"datetime.datetime.now(datetime.UTC).",
DeprecationWarning,