Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated datetime.utcnow() by datetime.now(timezone.utc) #979

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bdrung
Copy link

@bdrung bdrung commented Mar 5, 2025

Description

The feature or problem addressed by this PR

The utcnow function has been deprecated starting from Python 3.12: https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow

What your changes do and why you chose this solution

Thus replace datetime.datetime.utcnow() by datetime.datetime.now(datetime.timezone.utc). Also replace pytz with standard Python.

Fixes: #934

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

The `utcnow` function has been deprecated starting from Python 3.12:
https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow

Thus replace `datetime.datetime.utcnow()` by
`datetime.datetime.now(datetime.timezone.utc)`. Also replace `pytz` with
standard Python.

Fixes: IdentityPython#934
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
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
1 participant