[Python-modules-commits] [python-django] 01/06: Import python-django_1.8.7.orig.tar.gz

Luke Faraone lfaraone at moszumanska.debian.org
Wed Nov 25 05:34:22 UTC 2015


This is an automated email from the git hooks/post-receive script.

lfaraone pushed a commit to branch debian/master
in repository python-django.

commit 8dd68eb3da5a210762b7c540a252f1785e972297
Author: Luke Faraone <lfaraone at debian.org>
Date:   Wed Nov 25 04:21:13 2015 +0000

    Import python-django_1.8.7.orig.tar.gz
---
 AUTHORS                                            |   1 +
 Django.egg-info/PKG-INFO                           |   2 +-
 Django.egg-info/SOURCES.txt                        |   3 +
 PKG-INFO                                           |   2 +-
 django/__init__.py                                 |   2 +-
 django/contrib/postgres/fields/array.py            |  22 ++++--
 django/contrib/postgres/fields/ranges.py           |  24 ++++--
 django/contrib/postgres/fields/utils.py            |   3 +
 django/db/backends/mysql/operations.py             |   4 +-
 django/db/migrations/loader.py                     |   5 +-
 django/db/models/base.py                           |   8 +-
 django/db/models/deletion.py                       |   4 +-
 django/db/models/fields/related.py                 |  13 ++++
 django/db/models/query.py                          |  16 +++-
 django/db/utils.py                                 |  35 +++++----
 django/forms/models.py                             |  10 ++-
 django/template/engine.py                          |   8 +-
 django/utils/dateformat.py                         |  34 ++++++--
 django/utils/formats.py                            |  20 +++++
 django/utils/six.py                                |  74 ++++++++++++------
 django/utils/translation/trans_real.py             |   1 +
 docs/_ext/djangodocs.py                            |  30 ++++---
 .../djangodocs/static/docicons-behindscenes.png    | Bin 2269 -> 1065 bytes
 docs/_theme/djangodocs/static/docicons-note.png    | Bin 1013 -> 559 bytes
 .../djangodocs/static/docicons-philosophy.png      | Bin 1523 -> 791 bytes
 docs/conf.py                                       |   8 +-
 docs/howto/custom-management-commands.txt          |  15 ++++
 docs/howto/deployment/wsgi/modwsgi.txt             |  35 ++++-----
 docs/howto/deployment/wsgi/uwsgi.txt               |  11 +++
 docs/index.txt                                     |   2 +-
 docs/ref/contrib/admin/admindocs.txt               |   1 +
 docs/ref/contrib/admin/index.txt                   |  83 ++++++++++++++++++++
 docs/ref/contrib/gis/db-api.txt                    |   8 +-
 docs/ref/contrib/gis/geos.txt                      |  24 ++++--
 docs/ref/databases.txt                             |   7 +-
 docs/ref/django-admin.txt                          |  13 ++--
 docs/ref/forms/fields.txt                          |   3 +
 docs/ref/migration-operations.txt                  |   4 +-
 docs/ref/models/fields.txt                         |  10 ++-
 docs/ref/models/querysets.txt                      |   2 +-
 docs/ref/settings.txt                              |   9 ++-
 docs/ref/templates/api.txt                         |   2 +
 docs/ref/templates/builtins.txt                    |   4 +-
 docs/ref/unicode.txt                               |  30 +++++++
 docs/ref/urlresolvers.txt                          |   4 +-
 docs/releases/1.7.11.txt                           |  26 +++++++
 docs/releases/1.7.txt                              |   2 +-
 docs/releases/1.8.7.txt                            |  66 ++++++++++++++++
 docs/releases/index.txt                            |   2 +
 docs/topics/auth/customizing.txt                   |  12 +--
 docs/topics/auth/default.txt                       |  11 +++
 docs/topics/class-based-views/generic-editing.txt  |   6 +-
 docs/topics/db/aggregation.txt                     |  86 +++++++++++++++------
 docs/topics/db/multi-db.txt                        |   1 +
 docs/topics/i18n/translation.txt                   |   6 +-
 docs/topics/logging.txt                            |  46 ++++++-----
 docs/topics/performance.txt                        |  10 +--
 docs/topics/testing/tools.txt                      |   6 ++
 setup.cfg                                          |   2 +-
 tests/admin_filters/tests.py                       |   8 +-
 tests/apps/tests.py                                |  14 ++--
 tests/backends/tests.py                            |   1 +
 tests/basic/models.py                              |   1 +
 tests/basic/tests.py                               |  11 +++
 tests/delete/models.py                             |   6 ++
 tests/delete/tests.py                              |  11 +++
 tests/forms_tests/tests/tests.py                   |  14 +++-
 tests/i18n/tests.py                                |  15 ++++
 tests/model_fields/tests.py                        |  32 +++++++-
 tests/model_regress/test_pickle.py                 |  17 +---
 tests/multiple_database/tests.py                   |  21 +++++
 tests/order_with_respect_to/models.py              |  16 ++++
 tests/order_with_respect_to/tests.py               |  12 ++-
 tests/postgres_tests/test_array.py                 |  81 +++++++++++++++++++
 tests/postgres_tests/test_ranges.py                |  23 ++++--
 tests/prefetch_related/tests.py                    |  22 ++++++
 tests/queryset_pickle/tests.py                     |  17 +---
 tests/requirements/mysql.txt                       |   2 +-
 tests/runtests.py                                  |   2 +
 tests/schema/tests.py                              |  27 +++----
 tests/utils_tests/test_dateformat.py               |  17 ++++
 81 files changed, 969 insertions(+), 279 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 0a1ed3e..63855d7 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -657,6 +657,7 @@ answer newbie questions, and generally made Django that much better:
     Terry Huang <terryh.tp at gmail.com>
     thebjorn <bp at datakortet.no>
     Thejaswi Puthraya <thejaswi.puthraya at gmail.com>
+    Thijs van Dien <thijs at vandien.net>
     Thomas Chaumeny <t.chaumeny at gmail.com>
     Thomas Güttler <hv at tbz-pariv.de>
     Thomas Kerpe <thomas at kerpe.net>
diff --git a/Django.egg-info/PKG-INFO b/Django.egg-info/PKG-INFO
index 8af5a88..510abdd 100644
--- a/Django.egg-info/PKG-INFO
+++ b/Django.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: Django
-Version: 1.8.6
+Version: 1.8.7
 Summary: A high-level Python Web framework that encourages rapid development and clean, pragmatic design.
 Home-page: http://www.djangoproject.com/
 Author: Django Software Foundation
diff --git a/Django.egg-info/SOURCES.txt b/Django.egg-info/SOURCES.txt
index 59fd088..be483e1 100644
--- a/Django.egg-info/SOURCES.txt
+++ b/Django.egg-info/SOURCES.txt
@@ -2094,6 +2094,7 @@ django/contrib/postgres/fields/__init__.py
 django/contrib/postgres/fields/array.py
 django/contrib/postgres/fields/hstore.py
 django/contrib/postgres/fields/ranges.py
+django/contrib/postgres/fields/utils.py
 django/contrib/postgres/forms/__init__.py
 django/contrib/postgres/forms/array.py
 django/contrib/postgres/forms/hstore.py
@@ -3390,6 +3391,7 @@ docs/releases/1.6.9.txt
 docs/releases/1.6.txt
 docs/releases/1.7.1.txt
 docs/releases/1.7.10.txt
+docs/releases/1.7.11.txt
 docs/releases/1.7.2.txt
 docs/releases/1.7.3.txt
 docs/releases/1.7.4.txt
@@ -3405,6 +3407,7 @@ docs/releases/1.8.3.txt
 docs/releases/1.8.4.txt
 docs/releases/1.8.5.txt
 docs/releases/1.8.6.txt
+docs/releases/1.8.7.txt
 docs/releases/1.8.txt
 docs/releases/index.txt
 docs/releases/security.txt
diff --git a/PKG-INFO b/PKG-INFO
index 8af5a88..510abdd 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: Django
-Version: 1.8.6
+Version: 1.8.7
 Summary: A high-level Python Web framework that encourages rapid development and clean, pragmatic design.
 Home-page: http://www.djangoproject.com/
 Author: Django Software Foundation
diff --git a/django/__init__.py b/django/__init__.py
index fd0591d..98f98e3 100644
--- a/django/__init__.py
+++ b/django/__init__.py
@@ -1,6 +1,6 @@
 from django.utils.version import get_version
 
-VERSION = (1, 8, 6, 'final', 0)
+VERSION = (1, 8, 7, 'final', 0)
 
 __version__ = get_version(VERSION)
 
diff --git a/django/contrib/postgres/fields/array.py b/django/contrib/postgres/fields/array.py
index 970355f..8776061 100644
--- a/django/contrib/postgres/fields/array.py
+++ b/django/contrib/postgres/fields/array.py
@@ -5,15 +5,13 @@ from django.contrib.postgres.forms import SimpleArrayField
 from django.contrib.postgres.validators import ArrayMaxLengthValidator
 from django.core import checks, exceptions
 from django.db.models import Field, IntegerField, Transform
+from django.db.models.lookups import Exact
 from django.utils import six
 from django.utils.translation import string_concat, ugettext_lazy as _
 
-__all__ = ['ArrayField']
-
+from .utils import AttributeSetter
 
-class AttributeSetter(object):
-    def __init__(self, name, value):
-        setattr(self, name, value)
+__all__ = ['ArrayField']
 
 
 class ArrayField(Field):
@@ -165,7 +163,7 @@ class ArrayField(Field):
 class ArrayContains(lookups.DataContains):
     def as_sql(self, qn, connection):
         sql, params = super(ArrayContains, self).as_sql(qn, connection)
-        sql += '::%s' % self.lhs.output_field.db_type(connection)
+        sql = '%s::%s' % (sql, self.lhs.output_field.db_type(connection))
         return sql, params
 
 
@@ -173,7 +171,15 @@ class ArrayContains(lookups.DataContains):
 class ArrayContainedBy(lookups.ContainedBy):
     def as_sql(self, qn, connection):
         sql, params = super(ArrayContainedBy, self).as_sql(qn, connection)
-        sql += '::%s' % self.lhs.output_field.db_type(connection)
+        sql = '%s::%s' % (sql, self.lhs.output_field.db_type(connection))
+        return sql, params
+
+
+ at ArrayField.register_lookup
+class ArrayExact(Exact):
+    def as_sql(self, qn, connection):
+        sql, params = super(ArrayExact, self).as_sql(qn, connection)
+        sql = '%s::%s' % (sql, self.lhs.output_field.db_type(connection))
         return sql, params
 
 
@@ -181,7 +187,7 @@ class ArrayContainedBy(lookups.ContainedBy):
 class ArrayOverlap(lookups.Overlap):
     def as_sql(self, qn, connection):
         sql, params = super(ArrayOverlap, self).as_sql(qn, connection)
-        sql += '::%s' % self.lhs.output_field.db_type(connection)
+        sql = '%s::%s' % (sql, self.lhs.output_field.db_type(connection))
         return sql, params
 
 
diff --git a/django/contrib/postgres/fields/ranges.py b/django/contrib/postgres/fields/ranges.py
index 679e87f..fe69b08 100644
--- a/django/contrib/postgres/fields/ranges.py
+++ b/django/contrib/postgres/fields/ranges.py
@@ -6,6 +6,8 @@ from django.contrib.postgres import forms, lookups
 from django.db import models
 from django.utils import six
 
+from .utils import AttributeSetter
+
 __all__ = [
     'RangeField', 'IntegerRangeField', 'BigIntegerRangeField',
     'FloatRangeField', 'DateTimeRangeField', 'DateRangeField',
@@ -26,22 +28,32 @@ class RangeField(models.Field):
 
     def to_python(self, value):
         if isinstance(value, six.string_types):
-            value = self.range_type(**json.loads(value))
+            # Assume we're deserializing
+            vals = json.loads(value)
+            for end in ('lower', 'upper'):
+                if end in vals:
+                    vals[end] = self.base_field.to_python(vals[end])
+            value = self.range_type(**vals)
         elif isinstance(value, (list, tuple)):
             value = self.range_type(value[0], value[1])
         return value
 
+    def set_attributes_from_name(self, name):
+        super(RangeField, self).set_attributes_from_name(name)
+        self.base_field.set_attributes_from_name(name)
+
     def value_to_string(self, obj):
         value = self._get_val_from_obj(obj)
         if value is None:
             return None
         if value.isempty:
             return json.dumps({"empty": True})
-        return json.dumps({
-            "lower": value.lower,
-            "upper": value.upper,
-            "bounds": value._bounds,
-        })
+        base_field = self.base_field
+        result = {"bounds": value._bounds}
+        for end in ('lower', 'upper'):
+            obj = AttributeSetter(base_field.attname, getattr(value, end))
+            result[end] = base_field.value_to_string(obj)
+        return json.dumps(result)
 
     def formfield(self, **kwargs):
         kwargs.setdefault('form_class', self.form_field)
diff --git a/django/contrib/postgres/fields/utils.py b/django/contrib/postgres/fields/utils.py
new file mode 100644
index 0000000..424a78f
--- /dev/null
+++ b/django/contrib/postgres/fields/utils.py
@@ -0,0 +1,3 @@
+class AttributeSetter(object):
+    def __init__(self, name, value):
+        setattr(self, name, value)
diff --git a/django/db/backends/mysql/operations.py b/django/db/backends/mysql/operations.py
index bc53f59..ee01a7e 100644
--- a/django/db/backends/mysql/operations.py
+++ b/django/db/backends/mysql/operations.py
@@ -13,8 +13,8 @@ class DatabaseOperations(BaseDatabaseOperations):
 
     # MySQL stores positive fields as UNSIGNED ints.
     integer_field_ranges = dict(BaseDatabaseOperations.integer_field_ranges,
-        PositiveSmallIntegerField=(0, 4294967295),
-        PositiveIntegerField=(0, 18446744073709551615),
+        PositiveSmallIntegerField=(0, 65535),
+        PositiveIntegerField=(0, 4294967295),
     )
 
     def date_extract_sql(self, lookup_type, field_name):
diff --git a/django/db/migrations/loader.py b/django/db/migrations/loader.py
index 35266a7..bbd60a6 100644
--- a/django/db/migrations/loader.py
+++ b/django/db/migrations/loader.py
@@ -97,6 +97,7 @@ class MigrationLoader(object):
                         migration_names.add(import_name)
             # Load them
             south_style_migrations = False
+            django_style_migrations = False
             for migration_name in migration_names:
                 try:
                     migration_module = import_module("%s.%s" % (module_name, migration_name))
@@ -115,8 +116,10 @@ class MigrationLoader(object):
                     south_style_migrations = True
                     break
                 self.disk_migrations[app_config.label, migration_name] = migration_module.Migration(migration_name, app_config.label)
+                django_style_migrations = True
+
             if south_style_migrations:
-                if app_config.label in self.migrated_apps:
+                if django_style_migrations:
                     raise BadMigrationError(
                         "Migrated app %r contains South migrations. Make sure "
                         "all numbered South migrations are deleted prior to "
diff --git a/django/db/models/base.py b/django/db/models/base.py
index c237889..e94c14f 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -630,7 +630,7 @@ class Model(six.with_metaclass(ModelBase)):
                 rel_instance = getattr(self, field.get_cache_name())
                 local_val = getattr(db_instance, field.attname)
                 related_val = None if rel_instance is None else getattr(rel_instance, field.related_field.attname)
-                if local_val != related_val:
+                if local_val != related_val or (local_val is None and related_val is None):
                     del self.__dict__[field.get_cache_name()]
         self._state.db = db_instance._state.db
 
@@ -1674,13 +1674,13 @@ class Model(six.with_metaclass(ModelBase)):
 def method_set_order(ordered_obj, self, id_list, using=None):
     if using is None:
         using = DEFAULT_DB_ALIAS
-    rel_val = getattr(self, ordered_obj._meta.order_with_respect_to.rel.field_name)
-    order_name = ordered_obj._meta.order_with_respect_to.name
+    order_wrt = ordered_obj._meta.order_with_respect_to
+    filter_args = order_wrt.get_forward_related_filter(self)
     # FIXME: It would be nice if there was an "update many" version of update
     # for situations like this.
     with transaction.atomic(using=using, savepoint=False):
         for i, j in enumerate(id_list):
-            ordered_obj.objects.filter(**{'pk': j, order_name: rel_val}).update(_order=i)
+            ordered_obj.objects.filter(pk=j, **filter_args).update(_order=i)
 
 
 def method_get_order(ordered_obj, self):
diff --git a/django/db/models/deletion.py b/django/db/models/deletion.py
index 02b8cf3..c604fac 100644
--- a/django/db/models/deletion.py
+++ b/django/db/models/deletion.py
@@ -58,9 +58,9 @@ def get_candidate_relations_to_delete(opts):
     candidate_models = {opts}
     candidate_models = candidate_models.union(opts.concrete_model._meta.proxied_children)
     # For each model, get all candidate fields.
-    candidate_model_fields = chain.from_iterable(
+    candidate_model_fields = set(chain.from_iterable(
         opts.get_fields(include_hidden=True) for opts in candidate_models
-    )
+    ))
     # The candidate relations are the ones that come from N-1 and 1-1 relations.
     # N-N  (i.e., many-to-many) relations aren't candidates for deletion.
     return (
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
index 47b479c..f64ca22 100644
--- a/django/db/models/fields/related.py
+++ b/django/db/models/fields/related.py
@@ -314,6 +314,19 @@ class RelatedField(Field):
         else:
             self.do_related_class(other, cls)
 
+    def get_forward_related_filter(self, obj):
+        """
+        Return the keyword arguments that when supplied to
+        self.model.object.filter(), would select all instances related through
+        this field to the remote obj. This is used to build the querysets
+        returned by related descriptors. obj is an instance of
+        self.related_field.model.
+        """
+        return {
+            '%s__%s' % (self.name, rh_field.name): getattr(obj, rh_field.attname)
+            for _, rh_field in self.related_fields
+        }
+
     @property
     def swappable_setting(self):
         """
diff --git a/django/db/models/query.py b/django/db/models/query.py
index d76057e..0a73684 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -1631,10 +1631,24 @@ def prefetch_one_level(instances, prefetcher, lookup, level):
         rel_attr_val = rel_obj_attr(rel_obj)
         rel_obj_cache.setdefault(rel_attr_val, []).append(rel_obj)
 
+    to_attr, as_attr = lookup.get_current_to_attr(level)
+    # Make sure `to_attr` does not conflict with a field.
+    if as_attr and instances:
+        # We assume that objects retrieved are homogeneous (which is the premise
+        # of prefetch_related), so what applies to first object applies to all.
+        model = instances[0].__class__
+        try:
+            model._meta.get_field(to_attr)
+        except exceptions.FieldDoesNotExist:
+            pass
+        else:
+            msg = 'to_attr={} conflicts with a field on the {} model.'
+            raise ValueError(msg.format(to_attr, model.__name__))
+
     for obj in instances:
         instance_attr_val = instance_attr(obj)
         vals = rel_obj_cache.get(instance_attr_val, [])
-        to_attr, as_attr = lookup.get_current_to_attr(level)
+
         if single:
             val = vals[0] if vals else None
             to_attr = to_attr if as_attr else cache_name
diff --git a/django/db/utils.py b/django/db/utils.py
index e442ac1..ccfcfd4 100644
--- a/django/db/utils.py
+++ b/django/db/utils.py
@@ -326,30 +326,35 @@ class ConnectionRouter(object):
                     method = router.allow_migrate
                 except AttributeError:
                     method = router.allow_syncdb
+                    has_deprecated_signature = True
                     warnings.warn(
                         'Router.allow_syncdb has been deprecated and will stop working in Django 1.9. '
                         'Rename the method to allow_migrate.',
                         RemovedInDjango19Warning, stacklevel=2)
+                else:
+                    if HAS_INSPECT_SIGNATURE:
+                        sig = inspect.signature(method)
+                        has_deprecated_signature = not any(
+                            p.kind == inspect.Parameter.VAR_KEYWORD for p in sig.parameters.values()
+                        )
+                    else:
+                        argspec = inspect.getargspec(method)
+                        has_deprecated_signature = len(argspec.args) == 3 and not argspec.keywords
+                    if has_deprecated_signature:
+                        # Raised here because allow_syncdb has to be called with
+                        # the deprecated signature but shouldn't show this
+                        # warning (only the deprecated method one)
+                        warnings.warn(
+                            "The signature of allow_migrate has changed from "
+                            "allow_migrate(self, db, model) to "
+                            "allow_migrate(self, db, app_label, model_name=None, **hints). "
+                            "Support for the old signature will be removed in Django 1.10.",
+                            RemovedInDjango110Warning)
             except AttributeError:
                 # If the router doesn't have a method, skip to the next one.
                 continue
 
-            if HAS_INSPECT_SIGNATURE:
-                sig = inspect.signature(router.allow_migrate)
-                has_deprecated_signature = not any(
-                    p.kind == inspect.Parameter.VAR_KEYWORD for p in sig.parameters.values()
-                )
-            else:
-                argspec = inspect.getargspec(router.allow_migrate)
-                has_deprecated_signature = len(argspec.args) == 3 and not argspec.keywords
-
             if has_deprecated_signature:
-                warnings.warn(
-                    "The signature of allow_migrate has changed from "
-                    "allow_migrate(self, db, model) to "
-                    "allow_migrate(self, db, app_label, model_name=None, **hints). "
-                    "Support for the old signature will be removed in Django 1.10.",
-                    RemovedInDjango110Warning)
                 model = hints.get('model')
                 allow = None if model is None else method(db, model)
             else:
diff --git a/django/forms/models.py b/django/forms/models.py
index 1036e9b..384dddf 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -1092,17 +1092,19 @@ class ModelChoiceIterator(object):
     def __iter__(self):
         if self.field.empty_label is not None:
             yield ("", self.field.empty_label)
-        method = 'all' if self.queryset._prefetch_related_lookups else 'iterator'
-        queryset = getattr(self.queryset, method)
+        queryset = self.queryset.all()
+        # Can't use iterator() when queryset uses prefetch_related()
+        if not queryset._prefetch_related_lookups:
+            queryset = queryset.iterator()
         if self.field.cache_choices:
             if self.field.choice_cache is None:
                 self.field.choice_cache = [
-                    self.choice(obj) for obj in queryset()
+                    self.choice(obj) for obj in queryset
                 ]
             for choice in self.field.choice_cache:
                 yield choice
         else:
-            for obj in queryset():
+            for obj in queryset:
                 yield self.choice(obj)
 
     def __len__(self):
diff --git a/django/template/engine.py b/django/template/engine.py
index f6547ac..365fb12 100644
--- a/django/template/engine.py
+++ b/django/template/engine.py
@@ -185,7 +185,7 @@ class Engine(object):
         else:
             warnings.warn(
                 "The context_instance argument of render_to_string is "
-                "deprecated.", RemovedInDjango110Warning, stacklevel=2)
+                "deprecated.", RemovedInDjango110Warning, stacklevel=3)
         if dirs is _dirs_undefined:
             # Do not set dirs to None here to avoid triggering the deprecation
             # warning in select_template or get_template.
@@ -193,13 +193,13 @@ class Engine(object):
         else:
             warnings.warn(
                 "The dirs argument of render_to_string is deprecated.",
-                RemovedInDjango110Warning, stacklevel=2)
+                RemovedInDjango110Warning, stacklevel=3)
         if dictionary is _dictionary_undefined:
             dictionary = None
         else:
             warnings.warn(
                 "The dictionary argument of render_to_string was renamed to "
-                "context.", RemovedInDjango110Warning, stacklevel=2)
+                "context.", RemovedInDjango110Warning, stacklevel=3)
             context = dictionary
 
         if isinstance(template_name, (list, tuple)):
@@ -231,7 +231,7 @@ class Engine(object):
         else:
             warnings.warn(
                 "The dirs argument of select_template is deprecated.",
-                RemovedInDjango110Warning, stacklevel=2)
+                RemovedInDjango110Warning, stacklevel=3)
 
         if not template_name_list:
             raise TemplateDoesNotExist("No template names provided")
diff --git a/django/utils/dateformat.py b/django/utils/dateformat.py
index f4de4e7..ea55eaa 100644
--- a/django/utils/dateformat.py
+++ b/django/utils/dateformat.py
@@ -136,6 +136,8 @@ class TimeFormat(Formatter):
             return ""
 
         seconds = self.Z()
+        if seconds == "":
+            return ""
         sign = '-' if seconds < 0 else '+'
         seconds = abs(seconds)
         return "%s%02d%02d" % (sign, seconds // 3600, (seconds // 60) % 60)
@@ -167,7 +169,14 @@ class TimeFormat(Formatter):
         if not self.timezone:
             return ""
 
-        name = self.timezone.tzname(self.data) if self.timezone else None
+        name = None
+        try:
+            name = self.timezone.tzname(self.data)
+        except Exception:
+            # pytz raises AmbiguousTimeError during the autumn DST change.
+            # This happens mainly when __init__ receives a naive datetime
+            # and sets self.timezone = get_default_timezone().
+            pass
         if name is None:
             name = self.format('O')
         return six.text_type(name)
@@ -188,7 +197,14 @@ class TimeFormat(Formatter):
         if not self.timezone:
             return ""
 
-        offset = self.timezone.utcoffset(self.data)
+        try:
+            offset = self.timezone.utcoffset(self.data)
+        except Exception:
+            # pytz raises AmbiguousTimeError during the autumn DST change.
+            # This happens mainly when __init__ receives a naive datetime
+            # and sets self.timezone = get_default_timezone().
+            return ""
+
         # `offset` is a datetime.timedelta. For negative values (to the west of
         # UTC) only days can be negative (days=-1) and seconds are always
         # positive. e.g. UTC-1 -> timedelta(days=-1, seconds=82800, microseconds=0)
@@ -228,10 +244,16 @@ class DateFormat(TimeFormat):
 
     def I(self):
         "'1' if Daylight Savings Time, '0' otherwise."
-        if self.timezone and self.timezone.dst(self.data):
-            return '1'
-        else:
-            return '0'
+        try:
+            if self.timezone and self.timezone.dst(self.data):
+                return '1'
+            else:
+                return '0'
+        except Exception:
+            # pytz raises AmbiguousTimeError during the autumn DST change.
+            # This happens mainly when __init__ receives a naive datetime
+            # and sets self.timezone = get_default_timezone().
+            return ''
 
     def j(self):
         "Day of the month without leading zeros; i.e. '1' to '31'"
diff --git a/django/utils/formats.py b/django/utils/formats.py
index 30ab3e0..767871b 100644
--- a/django/utils/formats.py
+++ b/django/utils/formats.py
@@ -33,6 +33,24 @@ ISO_INPUT_FORMATS = {
 }
 
 
+FORMAT_SETTINGS = frozenset([
+    'DECIMAL_SEPARATOR',
+    'THOUSAND_SEPARATOR',
+    'NUMBER_GROUPING',
+    'FIRST_DAY_OF_WEEK',
+    'MONTH_DAY_FORMAT',
+    'TIME_FORMAT',
+    'DATE_FORMAT',
+    'DATETIME_FORMAT',
+    'SHORT_DATE_FORMAT',
+    'SHORT_DATETIME_FORMAT',
+    'YEAR_MONTH_FORMAT',
+    'DATE_INPUT_FORMATS',
+    'TIME_INPUT_FORMATS',
+    'DATETIME_INPUT_FORMATS',
+])
+
+
 def reset_format_cache():
     """Clear any cached formats.
 
@@ -95,6 +113,8 @@ def get_format(format_type, lang=None, use_l10n=None):
     be localized (or not), overriding the value of settings.USE_L10N.
     """
     format_type = force_str(format_type)
+    if format_type not in FORMAT_SETTINGS:
+        return format_type
     if use_l10n or (use_l10n is None and settings.USE_L10N):
         if lang is None:
             lang = get_language()
diff --git a/django/utils/six.py b/django/utils/six.py
index e92cb25..5262759 100644
--- a/django/utils/six.py
+++ b/django/utils/six.py
@@ -29,12 +29,13 @@ import sys
 import types
 
 __author__ = "Benjamin Peterson <benjamin at python.org>"
-__version__ = "1.9.0"
+__version__ = "1.10.0"
 
 
 # Useful for very coarse version differentiation.
 PY2 = sys.version_info[0] == 2
 PY3 = sys.version_info[0] == 3
+PY34 = sys.version_info[0:2] >= (3, 4)
 
 if PY3:
     string_types = str,
@@ -57,6 +58,7 @@ else:
     else:
         # It's possible to have sizeof(long) != sizeof(Py_ssize_t).
         class X(object):
+
             def __len__(self):
                 return 1 << 31
         try:
@@ -88,7 +90,7 @@ class _LazyDescr(object):
 
     def __get__(self, obj, tp):
         result = self._resolve()
-        setattr(obj, self.name, result) # Invokes __set__.
+        setattr(obj, self.name, result)  # Invokes __set__.
         try:
             # This is a bit ugly, but it avoids running this again by
             # removing this descriptor.
@@ -160,12 +162,14 @@ class MovedAttribute(_LazyDescr):
 
 
 class _SixMetaPathImporter(object):
+
     """
     A meta path importer to import six.moves and its submodules.
 
     This class implements a PEP302 finder and loader. It should be compatible
     with Python 2.5 and all existing versions of Python3
     """
+
     def __init__(self, six_module_name):
         self.name = six_module_name
         self.known_modules = {}
@@ -223,6 +227,7 @@ _importer = _SixMetaPathImporter(__name__)
 
 
 class _MovedItems(_LazyModule):
+
     """Lazy loading of moved objects"""
     __path__ = []  # mark as package
 
@@ -234,8 +239,10 @@ _moved_attributes = [
     MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"),
     MovedAttribute("intern", "__builtin__", "sys"),
     MovedAttribute("map", "itertools", "builtins", "imap", "map"),
+    MovedAttribute("getcwd", "os", "os", "getcwdu", "getcwd"),
+    MovedAttribute("getcwdb", "os", "os", "getcwd", "getcwdb"),
     MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"),
-    MovedAttribute("reload_module", "__builtin__", "imp", "reload"),
+    MovedAttribute("reload_module", "__builtin__", "importlib" if PY34 else "imp", "reload"),
     MovedAttribute("reduce", "__builtin__", "functools"),
     MovedAttribute("shlex_quote", "pipes", "shlex", "quote"),
     MovedAttribute("StringIO", "StringIO", "io"),
@@ -245,7 +252,6 @@ _moved_attributes = [
     MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"),
     MovedAttribute("zip", "itertools", "builtins", "izip", "zip"),
     MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"),
-
     MovedModule("builtins", "__builtin__"),
     MovedModule("configparser", "ConfigParser"),
     MovedModule("copyreg", "copy_reg"),
@@ -292,8 +298,13 @@ _moved_attributes = [
     MovedModule("urllib_robotparser", "robotparser", "urllib.robotparser"),
     MovedModule("xmlrpc_client", "xmlrpclib", "xmlrpc.client"),
     MovedModule("xmlrpc_server", "SimpleXMLRPCServer", "xmlrpc.server"),
-    MovedModule("winreg", "_winreg"),
 ]
+# Add windows specific modules.
+if sys.platform == "win32":
+    _moved_attributes += [
+        MovedModule("winreg", "_winreg"),
+    ]
+
 for attr in _moved_attributes:
     setattr(_MovedItems, attr.name, attr)
     if isinstance(attr, MovedModule):
@@ -307,6 +318,7 @@ _importer._add_module(moves, "moves")
 
 
 class Module_six_moves_urllib_parse(_LazyModule):
+
     """Lazy loading of moved objects in six.moves.urllib_parse"""
 
 
@@ -346,6 +358,7 @@ _importer._add_module(Module_six_moves_urllib_parse(__name__ + ".moves.urllib_pa
 
 
 class Module_six_moves_urllib_error(_LazyModule):
+
     """Lazy loading of moved objects in six.moves.urllib_error"""
 
 
@@ -365,6 +378,7 @@ _importer._add_module(Module_six_moves_urllib_error(__name__ + ".moves.urllib.er
 
 
 class Module_six_moves_urllib_request(_LazyModule):
+
     """Lazy loading of moved objects in six.moves.urllib_request"""
 
 
@@ -414,6 +428,7 @@ _importer._add_module(Module_six_moves_urllib_request(__name__ + ".moves.urllib.
 
 
 class Module_six_moves_urllib_response(_LazyModule):
+
     """Lazy loading of moved objects in six.moves.urllib_response"""
 
 
@@ -434,6 +449,7 @@ _importer._add_module(Module_six_moves_urllib_response(__name__ + ".moves.urllib
 
 
 class Module_six_moves_urllib_robotparser(_LazyModule):
+
     """Lazy loading of moved objects in six.moves.urllib_robotparser"""
 
 
@@ -451,6 +467,7 @@ _importer._add_module(Module_six_moves_urllib_robotparser(__name__ + ".moves.url
 
 
 class Module_six_moves_urllib(types.ModuleType):
+
     """Create a six.moves.urllib namespace that resembles the Python 3 namespace"""
     __path__ = []  # mark as package
     parse = _importer._get_module("moves.urllib_parse")
@@ -521,6 +538,9 @@ if PY3:
 
     create_bound_method = types.MethodType
 
+    def create_unbound_method(func, cls):
+        return func
+
     Iterator = object
 else:
     def get_unbound_function(unbound):
@@ -529,6 +549,9 @@ else:
     def create_bound_method(func, obj):
         return types.MethodType(func, obj, obj.__class__)
 
+    def create_unbound_method(func, cls):
+        return types.MethodType(func, None, cls)
+
     class Iterator(object):
 
         def next(self):
@@ -567,16 +590,16 @@ if PY3:
     viewitems = operator.methodcaller("items")
 else:
     def iterkeys(d, **kw):
-        return iter(d.iterkeys(**kw))
+        return d.iterkeys(**kw)
 
     def itervalues(d, **kw):
-        return iter(d.itervalues(**kw))
+        return d.itervalues(**kw)
 
     def iteritems(d, **kw):
-        return iter(d.iteritems(**kw))
+        return d.iteritems(**kw)
 
     def iterlists(d, **kw):
-        return iter(d.iterlists(**kw))
+        return d.iterlists(**kw)
 
     viewkeys = operator.methodcaller("viewkeys")
 
@@ -595,15 +618,13 @@ _add_doc(iterlists,
 if PY3:
     def b(s):
         return s.encode("latin-1")
+
     def u(s):
         return s
     unichr = chr
-    if sys.version_info[1] <= 1:
-        def int2byte(i):
-            return bytes((i,))
-    else:
-        # This is about 2x faster than the implementation above on 3.2+
-        int2byte = operator.methodcaller("to_bytes", 1, "big")
+    import struct
+    int2byte = struct.Struct(">B").pack
+    del struct
     byte2int = operator.itemgetter(0)
     indexbytes = operator.getitem
     iterbytes = iter
@@ -611,18 +632,25 @@ if PY3:
     StringIO = io.StringIO
     BytesIO = io.BytesIO
     _assertCountEqual = "assertCountEqual"
-    _assertRaisesRegex = "assertRaisesRegex"
-    _assertRegex = "assertRegex"
+    if sys.version_info[1] <= 1:
+        _assertRaisesRegex = "assertRaisesRegexp"
+        _assertRegex = "assertRegexpMatches"
+    else:
+        _assertRaisesRegex = "assertRaisesRegex"
+        _assertRegex = "assertRegex"
 else:
     def b(s):
         return s
     # Workaround for standalone backslash
+
     def u(s):
         return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape")
     unichr = unichr
     int2byte = chr
+
     def byte2int(bs):
         return ord(bs[0])
+
     def indexbytes(buf, i):
         return ord(buf[i])
     iterbytes = functools.partial(itertools.imap, ord)
@@ -650,7 +678,6 @@ def assertRegex(self, *args, **kwargs):
 if PY3:
     exec_ = getattr(moves.builtins, "exec")
 
-
     def reraise(tp, value, tb=None):
         if value is None:
             value = tp()
@@ -671,7 +698,6 @@ else:
             _locs_ = _globs_
         exec("""exec _code_ in _globs_, _locs_""")
 
-
     exec_("""def reraise(tp, value, tb=None):
     raise tp, value, tb
 """)
@@ -699,13 +725,14 @@ if print_ is None:
         fp = kwargs.pop("file", sys.stdout)
         if fp is None:
             return
+
         def write(data):
             if not isinstance(data, basestring):
                 data = str(data)
             # If the file has an encoding, encode unicode with it.
             if (isinstance(fp, file) and
-                isinstance(data, unicode) and
-                fp.encoding is not None):
+                    isinstance(data, unicode) and
+                    fp.encoding is not None):
                 errors = getattr(fp, "errors", None)
                 if errors is None:
                     errors = "strict"
@@ -748,6 +775,7 @@ if print_ is None:
         write(end)
 if sys.version_info[:2] < (3, 3):
     _print = print_
+
     def print_(*args, **kwargs):
         fp = kwargs.get("file", sys.stdout)
         flush = kwargs.pop("flush", False)
@@ -768,12 +796,14 @@ if sys.version_info[0:2] < (3, 4):
 else:
     wraps = functools.wraps
 
+
 def with_metaclass(meta, *bases):
     """Create a base class with a metaclass."""
     # This requires a bit of explanation: the basic idea is to make a dummy
     # metaclass for one level of class instantiation that replaces itself with
     # the actual metaclass.
     class metaclass(meta):
+
         def __new__(cls, name, this_bases, d):
             return meta(name, bases, d)
     return type.__new__(metaclass, 'temporary_class', (), {})
@@ -830,7 +860,7 @@ if sys.meta_path:
         # the six meta path importer, since the other six instance will have
         # inserted an importer with different class.
         if (type(importer).__name__ == "_SixMetaPathImporter" and
-            importer.name == __name__):
+                importer.name == __name__):
             del sys.meta_path[i]
             break
     del i, importer
diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py
index cd1ac1d..6e7ef9b 100644
--- a/django/utils/translation/trans_real.py
+++ b/django/utils/translation/trans_real.py
@@ -107,6 +107,7 @@ class DjangoTranslation(gettext_module.GNUTranslations):
     def __init__(self, language):
         """Create a GNUTranslations() using many locale directories"""
         gettext_module.GNUTranslations.__init__(self)
+        self.set_output_charset('utf-8')  # For Python 2 gettext() (#25720)
 
         self.__language = language
         self.__to_language = to_language(language)
diff --git a/docs/_ext/djangodocs.py b/docs/_ext/djangodocs.py
index 38f11df..fd93194 100644
--- a/docs/_ext/djangodocs.py
+++ b/docs/_ext/djangodocs.py
@@ -125,14 +125,8 @@ def visit_snippet_latex(self, node):
     """
     Latex document generator visit handler
     """
-    self.verbatim = ''
+    code = node.rawsource.rstrip('\n')
 
-
-def depart_snippet_latex(self, node):
-    """
-    Latex document generator depart handler.
-    """
-    code = self.verbatim.rstrip('\n')
     lang = self.hlsettingstack[-1][0]
     linenos = code.count('\n') >= self.hlsettingstack[-1][1] - 1
     fname = node['filename']
@@ -151,9 +145,14 @@ def depart_snippet_latex(self, node):
                                               linenos=linenos,
                                               **highlight_args)
 
-    self.body.append('\n{\\colorbox[rgb]{0.9,0.9,0.9}'
-                     '{\\makebox[\\textwidth][l]'
-                     '{\\small\\texttt{%s}}}}\n' % (fname,))
+    self.body.append(
+        '\n{\\colorbox[rgb]{0.9,0.9,0.9}'
+        '{\\makebox[\\textwidth][l]'
+        '{\\small\\texttt{%s}}}}\n' % (
+            # Some filenames have '_', which is special in latex.
+            fname.replace('_', r'\_'),
+        )
+    )
 
     if self.table:
         hlcode = hlcode.replace('\\begin{Verbatim}',
@@ -165,7 +164,16 @@ def depart_snippet_latex(self, node):
     hlcode = hlcode.rstrip() + '\n'
     self.body.append('\n' + hlcode + '\\end{%sVerbatim}\n' %
                      (self.table and 'Original' or ''))
-    self.verbatim = None
+
... 1834 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-django.git



More information about the Python-modules-commits mailing list