pysaml2
pysaml2 copied to clipboard
Fix deprecation warning for datetime.datetime.utcnow
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
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.
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.