Skip to content

Conversation

@kfrydel
Copy link

@kfrydel kfrydel commented Nov 3, 2023

Fixes #934

Description

Since Python 3.12, the utcnow function is deprecated - see, https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow

This commit turns usages of utcnow() into now(UTC).

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 fixes IdentityPython#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).
@c00kiemon5ter c00kiemon5ter added the next-release should become part of the next release label Nov 7, 2023
@bdrung
Copy link
Contributor

bdrung commented Mar 5, 2025

This merge request does not cover all cases of utcnow and datetime.UTC requires a recent Python version. I addressed those points in #979.

@c00kiemon5ter
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

next-release should become part of the next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pysaml2 raises DeprecationWarning: datetime.datetime.utcnow() when running tests with pytests on python 3.12

3 participants