mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #26764 -- Fixed Session.cycle_key() crash on unaccessed session.
This commit is contained in:
parent
b8e6e1b43b
commit
887f3d3219
@ -306,7 +306,10 @@ class SessionBase(object):
|
||||
"""
|
||||
Creates a new session key, while retaining the current session data.
|
||||
"""
|
||||
data = self._session_cache
|
||||
try:
|
||||
data = self._session_cache
|
||||
except AttributeError:
|
||||
data = {}
|
||||
key = self.session_key
|
||||
self.create()
|
||||
self._session_cache = data
|
||||
|
@ -188,6 +188,10 @@ class SessionTestsMixin(object):
|
||||
self.assertNotEqual(self.session.session_key, prev_key)
|
||||
self.assertEqual(list(self.session.items()), prev_data)
|
||||
|
||||
def test_cycle_with_no_session_cache(self):
|
||||
self.assertFalse(hasattr(self.session, '_session_cache'))
|
||||
self.session.cycle_key()
|
||||
|
||||
def test_save_doesnt_clear_data(self):
|
||||
self.session['a'] = 'b'
|
||||
self.session.save()
|
||||
|
Loading…
Reference in New Issue
Block a user