gh-103857: Document utcnow and utcfromtimestamp deprecations in What's New by hugovk · Pull Request #104542 · python/cpython

Re: #103857 (comment), add the deprecations to "What's New in 3.12".

Also fix a typo in a deprecation warning.


And should we clarify these warnings?

    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))
    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))

It's really datetime.datetime.utcnow() and datetime.datetime.utcfromtimestamp(), and not datetime.utcnow() and datetime.utcfromtimestamp().

Reason: to avoid confusion with datetime.UTC (which is not really datetime.datetime.UTC).


📚 Documentation preview 📚: https://cpython-previews--104542.org.readthedocs.build/en/104542/whatsnew/3.12.html#deprecated