diff options
| author | Ramiro Morales <cramm0@gmail.com> | 2011-06-09 20:01:28 +0000 |
|---|---|---|
| committer | Ramiro Morales <cramm0@gmail.com> | 2011-06-09 20:01:28 +0000 |
| commit | dff31de20aac85e4f4834c2466762cbf23fc0a7b (patch) | |
| tree | 6d7d6756f53eb599b81827bf097f24cfb1ed7b54 /django | |
| parent | da0c7cd7778ee99a31587276faee30e94a8255ae (diff) | |
Fixed #16155 -- Removed Python 2.4 compatibility constructs from code and mentions from docs. Thanks Aymeric Augustin for the report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16349 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/cache/__init__.py | 3 | ||||
| -rw-r--r-- | django/db/backends/oracle/base.py | 6 | ||||
| -rw-r--r-- | django/db/models/base.py | 9 | ||||
| -rw-r--r-- | django/http/__init__.py | 5 | ||||
| -rw-r--r-- | django/utils/hashcompat.py | 21 | ||||
| -rw-r--r-- | django/utils/http.py | 4 | ||||
| -rw-r--r-- | django/utils/itercompat.py | 2 | ||||
| -rw-r--r-- | django/utils/translation/trans_real.py | 3 |
8 files changed, 15 insertions, 38 deletions
diff --git a/django/core/cache/__init__.py b/django/core/cache/__init__.py index bb10e01c65..b76ddcf038 100644 --- a/django/core/cache/__init__.py +++ b/django/core/cache/__init__.py @@ -29,8 +29,7 @@ except ImportError: # Python 2.6 and greater from urlparse import parse_qsl except ImportError: - # Python 2.5, 2.4. Works on Python 2.6 but raises - # PendingDeprecationWarning + # Python 2.5. Works on Python 2.6 but raises PendingDeprecationWarning from cgi import parse_qsl __all__ = [ diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py index c024e6d7d0..c4642cafd6 100644 --- a/django/db/backends/oracle/base.py +++ b/django/db/backends/oracle/base.py @@ -176,12 +176,6 @@ WHEN (new.%(col_name)s IS NULL) # classes to normalize values from the database (the to_python # method is used for validation and isn't what we want here). elif isinstance(value, Database.Timestamp): - # In Python 2.3, the cx_Oracle driver returns its own - # Timestamp object that we must convert to a datetime class. - if not isinstance(value, datetime.datetime): - value = datetime.datetime(value.year, value.month, - value.day, value.hour, value.minute, value.second, - value.fsecond) if field and field.get_internal_type() == 'DateTimeField': pass elif field and field.get_internal_type() == 'DateField': diff --git a/django/db/models/base.py b/django/db/models/base.py index e75eb49695..31310ea0e7 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -915,10 +915,5 @@ def model_unpickle(model, attrs, factory): return cls.__new__(cls) model_unpickle.__safe_for_unpickle__ = True -if sys.version_info < (2, 5): - # Prior to Python 2.5, Exception was an old-style class - def subclass_exception(name, parents, unused): - return types.ClassType(name, parents, {}) -else: - def subclass_exception(name, parents, module): - return type(name, parents, {'__module__': module}) +def subclass_exception(name, parents, module): + return type(name, parents, {'__module__': module}) diff --git a/django/http/__init__.py b/django/http/__init__.py index ae507aac63..066346c181 100644 --- a/django/http/__init__.py +++ b/django/http/__init__.py @@ -17,13 +17,12 @@ except ImportError: # Python 2.6 and greater from urlparse import parse_qsl except ImportError: - # Python 2.5, 2.4. Works on Python 2.6 but raises - # PendingDeprecationWarning + # Python 2.5. Works on Python 2.6 but raises PendingDeprecationWarning from cgi import parse_qsl import Cookie # httponly support exists in Python 2.6's Cookie library, -# but not in Python 2.4 or 2.5. +# but not in Python 2.5. _morsel_supports_httponly = Cookie.Morsel._reserved.has_key('httponly') # Some versions of Python 2.7 and later won't need this encoding bug fix: _cookie_encodes_correctly = Cookie.SimpleCookie().value_encode(';') == (';', '"\\073"') diff --git a/django/utils/hashcompat.py b/django/utils/hashcompat.py index 57435b14be..b11fa0a686 100644 --- a/django/utils/hashcompat.py +++ b/django/utils/hashcompat.py @@ -3,22 +3,13 @@ The md5 and sha modules are deprecated since Python 2.5, replaced by the hashlib module containing both hash algorithms. Here, we provide a common interface to the md5 and sha constructors, depending on system version. """ -import sys -import warnings +import warnings warnings.warn("django.utils.hashcompat is deprecated; use hashlib instead", PendingDeprecationWarning) -if sys.version_info >= (2, 5): - import hashlib - md5_constructor = hashlib.md5 - md5_hmac = md5_constructor - sha_constructor = hashlib.sha1 - sha_hmac = sha_constructor -else: - import md5 - md5_constructor = md5.new - md5_hmac = md5 - import sha - sha_constructor = sha.new - sha_hmac = sha +import hashlib +md5_constructor = hashlib.md5 +md5_hmac = md5_constructor +sha_constructor = hashlib.sha1 +sha_hmac = sha_constructor diff --git a/django/utils/http.py b/django/utils/http.py index 4b43e5835e..07e96b9ba6 100644 --- a/django/utils/http.py +++ b/django/utils/http.py @@ -198,8 +198,8 @@ if sys.version_info >= (2, 6): p1, p2 = urlparse.urlparse(url1), urlparse.urlparse(url2) return (p1.scheme, p1.hostname, p1.port) == (p2.scheme, p2.hostname, p2.port) else: - # Python 2.4, 2.5 compatibility. This actually works for Python 2.6 and - # above, but the above definition is much more obviously correct and so is + # Python 2.5 compatibility. This actually works for Python 2.6 and above, + # but the above definition is much more obviously correct and so is # preferred going forward. def same_origin(url1, url2): """ diff --git a/django/utils/itercompat.py b/django/utils/itercompat.py index 38058e227c..a56b703983 100644 --- a/django/utils/itercompat.py +++ b/django/utils/itercompat.py @@ -7,7 +7,7 @@ these implementations if necessary. import itertools import warnings -# Fallback for Python 2.4, Python 2.5 +# Fallback for Python 2.5 def product(*args, **kwds): """ Taken from http://docs.python.org/library/itertools.html#itertools.product diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py index b497d9e354..9e8285bcf7 100644 --- a/django/utils/translation/trans_real.py +++ b/django/utils/translation/trans_real.py @@ -63,8 +63,7 @@ def to_language(locale): class DjangoTranslation(gettext_module.GNUTranslations): """ This class sets up the GNUTranslations context with regard to output - charset. Django uses a defined DEFAULT_CHARSET as the output charset on - Python 2.4. + charset. """ def __init__(self, *args, **kw): gettext_module.GNUTranslations.__init__(self, *args, **kw) |
