This is also notable because every SuspiciousOperation subclass gets its
own logger, so this is the only place that is logged via the
`django.security.SuspiciousOperation` logger.
This should only require:
{{{
diff --git django/contrib/sessions/middleware.py
django/contrib/sessions/middleware.py
index cb8c1ff45b..f8386a21ce 100644
--- django/contrib/sessions/middleware.py
+++ django/contrib/sessions/middleware.py
@@ -3,7 +3,7 @@ from importlib import import_module
from django.conf import settings
from django.contrib.sessions.backends.base import UpdateError
-from django.core.exceptions import SuspiciousOperation
+from django.contrib.sessions.exceptions import SuspiciousSession
from django.utils.cache import patch_vary_headers
from django.utils.deprecation import MiddlewareMixin
from django.utils.http import http_date
@@ -60,7 +60,7 @@ class SessionMiddleware(MiddlewareMixin):
try:
request.session.save()
except UpdateError:
- raise SuspiciousOperation(
+ raise SuspiciousSession(
"The request's session was deleted before the
"
"request completed. The user may have logged
"
"out in a concurrent request, for example."
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31962>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* has_patch: 1 => 0
* type: Uncategorized => Cleanup/optimization
* easy: 1 => 0
* stage: Unreviewed => Accepted
Comment:
`SuspiciousSession` is better than `SuspiciousOperation`, but it's not a
big improvement because this error is not really caused by user and there
is nothing suspicious in it (see #27363). I think we should use a new
exception class as
[https://github.com/django/django/pull/7431#discussion_r85209451 proposed
in the original PR].
--
Ticket URL: <https://code.djangoproject.com/ticket/31962#comment:1>
* owner: nobody => Hasan Ramezani
* status: new => assigned
Comment:
@felixxm
> I think we should use a new exception class
What do you think about `SessionInterrupted` as new exception class name?
--
Ticket URL: <https://code.djangoproject.com/ticket/31962#comment:2>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/13395 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/31962#comment:3>
* needs_better_patch: 0 => 1
* needs_tests: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/31962#comment:4>
* needs_better_patch: 1 => 0
* needs_tests: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/31962#comment:5>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/31962#comment:6>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"2808cdc8fb15ad27f83af3e62db69f5ea7ced29e" 2808cdc]:
{{{
#!CommitTicketReference repository=""
revision="2808cdc8fb15ad27f83af3e62db69f5ea7ced29e"
Fixed #31962 -- Made SessionMiddleware raise SessionInterrupted when
session destroyed while request is processing.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31962#comment:7>