8000 gh-106392: Fix inconsistency in deprecation warnings by wjandrea · Pull Request #106436 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-106392: Fix inconsistency in deprecation warnings #106436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump t 10000 o
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix inconsistency in deprecation warnings
They used "datetime" to refer to both the object and the module
  • Loading branch information
wjandrea committed Jul 4, 2023
commit 74f516dff0216ce6c2be6ebf3a673a956ab51d27
4 changes: 2 additions & 2 deletions Lib/_pydatetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,7 @@ def utcfromtimestamp(cls, t):
warnings.warn("datetime.utcfromtimestamp() is deprecated and scheduled "
"for removal in a future version. Use timezone-aware "
"objects to represent datetimes in UTC: "
"datetime.fromtimestamp(t, datetime.UTC).",
"datetime.datetime.fromtimestamp(t, datetime.UTC).",
DeprecationWarning,
stacklevel=2)
return cls._fromtimestamp(t, True, None)
Expand All @@ -1830,7 +1830,7 @@ def utcnow(cls):
warnings.warn("datetime.utcnow() is deprecated and scheduled for "
"removal in a future version. Instead, Use timezone-aware "
"objects to represent datetimes in UTC: "
"datetime.now(datetime.UTC).",
"datetime.datetime.now(datetime.UTC).",
DeprecationWarning,
stacklevel=2)
t = _time.time()
Expand Down
4 changes: 2 additions & 2 deletions Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -5138,7 +5138,7 @@ datetime_utcnow(PyObject *cls, PyObject *dummy)
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"datetime.utcnow() is deprecated and scheduled for removal in a "
"future version. Use timezone-aware objects to represent datetimes "
"in UTC: datetime.now(datetime.UTC).", 1))
"in UTC: datetime.datetime.now(datetime.UTC).", 1))
{
return NULL;
}
Expand Down Expand Up @@ -5181,7 +5181,7 @@ datetime_utcfromtimestamp(PyObject *cls, PyObject *args)
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"datetime.utcfromtimestamp() is deprecated and scheduled for removal "
"in a future version. Use timezone-aware objects to represent "
"datetimes in UTC: datetime.fromtimestamp(timestamp, datetime.UTC).", 1))
"datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).", 1))
{
return NULL;
}
Expand Down
0