Repository navigation
Fix CookieMiddleware.set_cookie() with aware expires on Django 5.0+ - #2238
Open
youssef-elaasri wants to merge 1 commit into
Open
youssef-elaasri wants to merge 1 commit into
youssef-elaasri wants to merge 1 commit into
Conversation
…o 5.0+. django.utils.timezone.utc was removed in Django 5.0.
Author
|
Friendly ping: is there anything I should change to get this reviewed? The CI workflows haven't run yet, I think they're waiting for approval since this is my first PR here. Happy to adjust if you'd prefer a different approach to the fix for #2237. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2237.
CookieMiddleware.set_cookie()passeddjango.utils.timezone.utctomake_naive()for timezone-awareexpiresvalues. Django removed that alias in 5.0, so the call raisedAttributeErroron every supported Django version. This usesdatetime.timezone.utcinstead, which is what the alias pointed to.Added
test_set_cookie_aware_expires. It fails onmainwith theAttributeErrorand passes with the fix.pytestpasses on Django 5.2 / Python 3.13, except the Selenium testtest_real_time_delete_message, which fails the same way onmainlocally.flake8,blackandisortare clean.