pysaml2 icon indicating copy to clipboard operation
pysaml2 copied to clipboard

Fix deprecation warning for datetime.datetime.utcnow

Open kfrydel opened this issue 2 years ago • 1 comments

This fixes #934. utcnow function, starting from Python 3.12 is deprecated: https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow

Thus, this commit turns usages of utcnow() into now(UTC).

Description

The feature or problem addressed by this PR

This addresses the issue described in #934

What your changes do and why you chose this solution

The solution is based on the suggestion from official Python docs: https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow

Checklist

  • [ ] Checked that no other issues or pull requests exist for the same issue/change
  • [ ] Added tests covering the new functionality
  • [ ] Updated documentation OR the change is too minor to be documented
  • [ ] Updated CHANGELOG.md OR changes are insignificant

kfrydel avatar Nov 03 '23 16:11 kfrydel

This merge request does not cover all cases of utcnow and datetime.UTC requires a recent Python version. I addressed those points in https://github.com/IdentityPython/pysaml2/pull/979.

bdrung avatar Mar 05 '25 14:03 bdrung

Thank you @kfrydel 👍

As @bdrung mentioned this PR is a good starting point but does not cover all cases.
I am closing this in favour of #979.

c00kiemon5ter avatar Oct 07 '25 14:10 c00kiemon5ter