Skip to content

Commit

Permalink
Adjust message to be less wordy
Browse files Browse the repository at this point in the history
  • Loading branch information
pganssle committed Apr 27, 2023
1 parent 97eff7f commit b223173
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
14 changes: 6 additions & 8 deletions Lib/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -1803,10 +1803,9 @@ def utcfromtimestamp(cls, t):
"""Construct a naive UTC datetime from a POSIX timestamp."""
import warnings
warnings.warn("datetime.utcfromtimestamp() is deprecated and scheduled "
"for removal in a future version. It is instead "
"recommended that users use timezone-aware objects to "
"represent datetimes in UTC. To get such an object from "
"a timestamp, use datetime.fromtimestamp(t, datetime.UTC).",
"for removal in a future version. Use timezone-aware "
"objects to represent datetimes in UTC: "
"datetime.fromtimestamp(t, datetime.UTC).",
DeprecationWarning,
stacklevel=2)
return cls._fromtimestamp(t, True, None)
Expand All @@ -1822,10 +1821,9 @@ 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. It is instead recommended "
"that users use timezone-aware objects to represent "
"datetimes in UTC. To get such an object representing "
"the current time, use datetime.now(datetime.UTC).",
"removal in a future version. Instead, Use timezone-aware "
"objects to represent datetimes in UTC: "
"datetime.now(datetime.UTC).",
DeprecationWarning,
stacklevel=2)
t = _time.time()
Expand Down
10 changes: 4 additions & 6 deletions Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -5147,9 +5147,8 @@ datetime_utcnow(PyObject *cls, PyObject *dummy)
PyErr_WarnEx(
PyExc_DeprecationWarning,
"datetime.utcnow() is deprecated and scheduled for removal in a future "
"version. It is instead recommended that users use timezone-aware "
"objects to represent datetimes in UTC. To get such an object "
"representing the current time, use datetime.now(datetime.UTC).",
"version. Use timezone-aware objects to represent datetimes in UTC: "
"datetime.now(datetime.UTC).",
2
);
return datetime_best_possible(cls, _PyTime_gmtime, Py_None);
Expand Down Expand Up @@ -5191,9 +5190,8 @@ datetime_utcfromtimestamp(PyObject *cls, PyObject *args)
PyErr_WarnEx(
PyExc_DeprecationWarning,
"datetime.utcfromtimestamp() is deprecated and scheduled for removal "
"in a future version. It is instead recommended that users use "
"timezone-aware objects to represent datetimes in UTC. To get such an "
"object from a timestamp, use datetime.fromtimestamp(t, datetime.UTC).",
"in a future version. Use timezone-aware objects to represent "
"datetimes in UTC: datetime.now(datetime.UTC).",
2
);
PyObject *timestamp;
Expand Down

0 comments on commit b223173

Please sign in to comment.