| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
I think _pydatetime.py presumably needs to be updated as well. |
Sorry, something went wrong.
There was a problem hiding this comment.
Looks right.
Sorry, something went wrong.
The stacklevel setting in the pure python implementation is actually correct because warning is generated inside a python,rather than a C function in this case: 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. Use timezone-aware "
"objects to represent datetimes in UTC: "
"datetime.fromtimestamp(t, datetime.UTC).",
DeprecationWarning,
stacklevel=2)
return cls._fromtimestamp(t, True, None)To test, create the following file: cat > test_103857.py
import sys
sys.modules['_datetime'] = None
from datetime import datetime
def f():
return datetime.utcfromtimestamp(0)
f()and run % ./python.exe -W always test_103857.py
/Users/a/Work/abalkin/cpython-1/test_103857.py:6: DeprecationWarning: 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).
return datetime.utcfromtimestamp(0) |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Set up
Before
Warnings don't point to the actual lines of code that calls the deprecated utcfromtimestamp and utcnow:
After
Now points to the actual lines of code directly calling utcfromtimestamp and utcnow: