Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #8310 -- Actually use the SystemRandom RNG, if available, which…

… fixes an

oversight from [8340]. The previous code worked, but this is what I really
intended.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8346 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 2da6628519be25c3eeb2a4d20edc29a30d9546e1 1 parent 4adf048
@malcolmt malcolmt authored
Showing with 3 additions and 3 deletions.
  1. +3 −3 django/contrib/sessions/backends/base.py
View
6 django/contrib/sessions/backends/base.py
@@ -15,9 +15,9 @@
# Use the system (hardware-based) random number generator if it exists.
if hasattr(random, 'SystemRandom'):
- randint = random.SystemRandom().randint
+ randrange = random.SystemRandom().randrange
else:
- randint = random.randint
+ randrange = random.randrange
MAX_SESSION_KEY = 18446744073709551616L # 2 << 63
class CreateError(Exception):
@@ -135,7 +135,7 @@ def _get_new_session_key(self):
pid = 1
while 1:
session_key = md5_constructor("%s%s%s%s"
- % (random.randrange(0, MAX_SESSION_KEY), pid, time.time(),
+ % (randrange(0, MAX_SESSION_KEY), pid, time.time(),
settings.SECRET_KEY)).hexdigest()
if not self.exists(session_key):
break
Please sign in to comment.
Something went wrong with that request. Please try again.