summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-07-01 12:02:17 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-07-01 12:02:17 +0200
commitd5589b4cd3238c4bf4063ddd8239d22b37caa7d3 (patch)
tree34a10064e210d88a65ef1203a7c00af971a8e467
parenta763915a03579868c6abdc5cdffbb4c398dc52ee (diff)
Removed some conditional code only needed under Python 2.6.
-rw-r--r--django/conf/__init__.py12
-rw-r--r--django/db/backends/sqlite3/base.py10
-rw-r--r--django/db/models/fields/related.py4
-rw-r--r--django/db/utils.py7
4 files changed, 8 insertions, 25 deletions
diff --git a/django/conf/__init__.py b/django/conf/__init__.py
index c98443be1a..c4b9634d83 100644
--- a/django/conf/__init__.py
+++ b/django/conf/__init__.py
@@ -59,14 +59,10 @@ class LazySettings(LazyObject):
Setup logging from LOGGING_CONFIG and LOGGING settings.
"""
if not sys.warnoptions:
- try:
- # Route warnings through python logging
- logging.captureWarnings(True)
- # Allow DeprecationWarnings through the warnings filters
- warnings.simplefilter("default", DeprecationWarning)
- except AttributeError:
- # No captureWarnings on Python 2.6, DeprecationWarnings are on anyway
- pass
+ # Route warnings through python logging
+ logging.captureWarnings(True)
+ # Allow DeprecationWarnings through the warnings filters
+ warnings.simplefilter("default", DeprecationWarning)
if self.LOGGING_CONFIG:
from django.utils.log import DEFAULT_LOGGING
diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py
index 92dbf354ae..4345790b06 100644
--- a/django/db/backends/sqlite3/base.py
+++ b/django/db/backends/sqlite3/base.py
@@ -78,14 +78,8 @@ Database.register_converter(str("decimal"), decoder(util.typecast_decimal))
Database.register_adapter(datetime.datetime, adapt_datetime_with_timezone_support)
Database.register_adapter(decimal.Decimal, util.rev_typecast_decimal)
-if Database.version_info >= (2, 4, 1):
- # Starting in 2.4.1, the str type is not accepted anymore, therefore,
- # we convert all str objects to Unicode
- # As registering a adapter for a primitive type causes a small
- # slow-down, this adapter is only registered for sqlite3 versions
- # needing it (Python 2.6 and up).
- Database.register_adapter(str, lambda s: s.decode('utf-8'))
- Database.register_adapter(SafeBytes, lambda s: s.decode('utf-8'))
+Database.register_adapter(str, lambda s: s.decode('utf-8'))
+Database.register_adapter(SafeBytes, lambda s: s.decode('utf-8'))
class DatabaseFeatures(BaseDatabaseFeatures):
# SQLite cannot handle us only partially reading from a cursor's result set
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
index ff222e1b85..1e7e73ddbe 100644
--- a/django/db/models/fields/related.py
+++ b/django/db/models/fields/related.py
@@ -1362,9 +1362,7 @@ class ManyToManyField(RelatedField):
assert not to._meta.abstract, "%s cannot define a relation with abstract class %s" % (self.__class__.__name__, to._meta.object_name)
except AttributeError: # to._meta doesn't exist, so it must be RECURSIVE_RELATIONSHIP_CONSTANT
assert isinstance(to, six.string_types), "%s(%r) is invalid. First parameter to ManyToManyField must be either a model, a model name, or the string %r" % (self.__class__.__name__, to, RECURSIVE_RELATIONSHIP_CONSTANT)
- # Python 2.6 and earlier require dictionary keys to be of str type,
- # not unicode and class names must be ASCII (in Python 2.x), so we
- # forcibly coerce it here (breaks early if there's a problem).
+ # Class names must be ASCII in Python 2.x, so we forcibly coerce it here to break early if there's a problem.
to = str(to)
kwargs['verbose_name'] = kwargs.get('verbose_name', None)
diff --git a/django/db/utils.py b/django/db/utils.py
index acb838f940..36b89d9acf 100644
--- a/django/db/utils.py
+++ b/django/db/utils.py
@@ -85,12 +85,7 @@ class DatabaseErrorWrapper(object):
):
db_exc_type = getattr(self.wrapper.Database, dj_exc_type.__name__)
if issubclass(exc_type, db_exc_type):
- # Under Python 2.6, exc_value can still be a string.
- try:
- args = tuple(exc_value.args)
- except AttributeError:
- args = (exc_value,)
- dj_exc_value = dj_exc_type(*args)
+ dj_exc_value = dj_exc_type(*exc_value.args)
dj_exc_value.__cause__ = exc_value
# Only set the 'errors_occurred' flag for errors that may make
# the connection unusable.