mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Removed a bunch of Python 2.4 workarounds now that we don't support it. Refs #15702 -- thanks to jonash for the patch. Splitting this over muliple commits to make it more manageable.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15926 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
6
django/core/cache/backends/filebased.py
vendored
6
django/core/cache/backends/filebased.py
vendored
@@ -1,15 +1,15 @@
|
||||
"File-based cache backend"
|
||||
|
||||
import hashlib
|
||||
import os
|
||||
import time
|
||||
import shutil
|
||||
import time
|
||||
try:
|
||||
import cPickle as pickle
|
||||
except ImportError:
|
||||
import pickle
|
||||
|
||||
from django.core.cache.backends.base import BaseCache
|
||||
from django.utils.hashcompat import md5_constructor
|
||||
|
||||
class FileBasedCache(BaseCache):
|
||||
def __init__(self, dir, params):
|
||||
@@ -145,7 +145,7 @@ class FileBasedCache(BaseCache):
|
||||
Thus, a cache key of "foo" gets turnned into a file named
|
||||
``{cache-dir}ac/bd/18db4cc2f85cedef654fccc4a4d8``.
|
||||
"""
|
||||
path = md5_constructor(key).hexdigest()
|
||||
path = hashlib.md5(key).hexdigest()
|
||||
path = os.path.join(path[:2], path[2:4], path[4:])
|
||||
return os.path.join(self._dir, path)
|
||||
|
||||
|
||||
8
django/core/cache/backends/locmem.py
vendored
8
django/core/cache/backends/locmem.py
vendored
@@ -77,12 +77,10 @@ class LocMemCache(BaseCache):
|
||||
key = self.make_key(key, version=version)
|
||||
self.validate_key(key)
|
||||
self._lock.writer_enters()
|
||||
# Python 2.4 doesn't allow combined try-except-finally blocks.
|
||||
try:
|
||||
try:
|
||||
self._set(key, pickle.dumps(value), timeout)
|
||||
except pickle.PickleError:
|
||||
pass
|
||||
self._set(key, pickle.dumps(value), timeout)
|
||||
except pickle.PickleError:
|
||||
pass
|
||||
finally:
|
||||
self._lock.writer_leaves()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user