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

Resolve deprecation warnings related to datetime.utcnow in python 3.12 #335

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

brouberol
Copy link

@brouberol brouberol commented Nov 1, 2023

When upgrading my project to python 3.12, I started seeing deprecation warnings related to the use of datetime.datetime.utcnow.

/Users/br/.../lib/python3.12/site-packages/jose/jwt.py:311: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
    now = timegm(datetime.utcnow().utctimetuple())

This PR simply implements the suggestion (in a backwards-compatible fashion), to get rid of these warnings in all projects depending on python-jose.

Regards

Fixes #334

Copy link

@Jamim Jamim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @brouberol,

Thank you for taking care of that warning!
I'd like to suggest a way to simplify your changes a bit.

jose/utils.py Outdated Show resolved Hide resolved
jose/utils.py Outdated Show resolved Hide resolved
Co-authored-by: Aliaksei Urbanski <aliaksei.urbanski@gmail.com>
@brouberol
Copy link
Author

Thanks @Jamim! Good call indeed

@phifuh
Copy link

phifuh commented Jan 22, 2024

will this be bundled into release 3.4 or just a minor update?

@Jamim
Copy link

Jamim commented Jan 22, 2024

Hello @phifuh,

will this be bundled into release 3.4 or just a minor update?

Sorry, but it looks like chances of this happening are near zero.

Best regards!

@phifuh
Copy link

phifuh commented Jan 23, 2024

@Jamim thats fair, eventually someone might fork this project and actively maintain it, at least thats what I hope

@spapanik
Copy link

spapanik commented Feb 2, 2024

@Jamim @phifuh I agree that there is a slim chance to get this change done, so I'm forking this, and I plan to create a successor for it. But, it seems like a lot of work to maintain multiple different backends, so I will keep cryptography and drop the rest.

@lsmith77
Copy link

lsmith77 commented Feb 2, 2024

guess it makes more sense to migrate to https://github.com/jpadilla/pyjwt

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.

Deprecation warning from python 3.12
5 participants