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

Fix datetime.utcnow() deprecations in SQLAlchemy backend #253

Open
markhobson opened this issue May 30, 2024 · 1 comment
Open

Fix datetime.utcnow() deprecations in SQLAlchemy backend #253

markhobson opened this issue May 30, 2024 · 1 comment

Comments

@markhobson
Copy link

datetime.utcnow() is now deprecated in Python 3.12. It is used by the SQLAlchemy backend:

xxx/.venv/lib/python3.12/site-packages/flask_session/sqlalchemy/sqlalchemy.py:168: 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).
    storage_expiration_datetime = datetime.utcnow() + session_lifetime

xxx/.venv/lib/python3.12/site-packages/flask_session/sqlalchemy/sqlalchemy.py:141: 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).
    if record and (record.expiry is None or record.expiry <= datetime.utcnow()):

Happy to submit a PR given guidance on how timezones should be handled.

GammaGames added a commit to GammaGames/flask-session that referenced this issue Jan 9, 2025
@GammaGames
Copy link

I tried to fix it in #275, tests look like they all passed

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

No branches or pull requests

2 participants