Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Imported zip from future_builtins instead of itertools.izip.

In Python 3, itertools.izip is not available any more (behaviour
integrated in standard zip).
  • Loading branch information...
commit 1aae1cba99b0f8232527742d64b120e4d902c68d 1 parent ecdd091
@claudep claudep authored
View
9 django/contrib/gis/db/models/sql/compiler.py
@@ -1,4 +1,5 @@
-from itertools import izip
+from future_builtins import zip
+
from django.db.backends.util import truncate_name, typecast_timestamp
from django.db.models.sql import compiler
from django.db.models.sql.constants import MULTI
@@ -32,7 +33,7 @@ def get_columns(self, with_aliases=False):
if self.query.select:
only_load = self.deferred_to_columns()
# This loop customized for GeoQuery.
- for col, field in izip(self.query.select, self.query.select_fields):
+ for col, field in zip(self.query.select, self.query.select_fields):
if isinstance(col, (list, tuple)):
alias, column = col
table = self.query.alias_map[alias].table_name
@@ -78,7 +79,7 @@ def get_columns(self, with_aliases=False):
])
# This loop customized for GeoQuery.
- for (table, col), field in izip(self.query.related_select_cols, self.query.related_select_fields):
+ for (table, col), field in zip(self.query.related_select_cols, self.query.related_select_fields):
r = self.get_field_select(field, table, col)
if with_aliases and col in col_aliases:
c_alias = 'Col%d' % len(col_aliases)
@@ -184,7 +185,7 @@ def resolve_columns(self, row, fields=()):
values = [self.query.convert_values(v,
self.query.extra_select_fields.get(a, None),
self.connection)
- for v, a in izip(row[rn_offset:index_start], aliases)]
+ for v, a in zip(row[rn_offset:index_start], aliases)]
if self.connection.ops.oracle or getattr(self.query, 'geo_values', False):
# We resolve the rest of the columns if we're on Oracle or if
# the `geo_values` attribute is defined.
View
4 django/contrib/gis/utils/ogrinspect.py
@@ -5,7 +5,7 @@
Author: Travis Pinney, Dane Springmeyer, & Justin Bronn
"""
-from itertools import izip
+from future_builtins import zip
# Requires GDAL to use.
from django.contrib.gis.gdal import DataSource
from django.contrib.gis.gdal.field import OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime
@@ -165,7 +165,7 @@ def get_kwargs_str(field_name):
yield 'class %s(models.Model):' % model_name
- for field_name, width, precision, field_type in izip(ogr_fields, layer.field_widths, layer.field_precisions, layer.field_types):
+ for field_name, width, precision, field_type in zip(ogr_fields, layer.field_widths, layer.field_precisions, layer.field_types):
# The model field name.
mfield = field_name.lower()
if mfield[-1:] == '_': mfield += 'field'
View
8 django/db/models/base.py
@@ -1,7 +1,7 @@
import copy
import sys
from functools import update_wrapper
-from itertools import izip
+from future_builtins import zip
import django.db.models.manager # Imported to register signal handler.
from django.conf import settings
@@ -292,15 +292,15 @@ def __init__(self, *args, **kwargs):
fields_iter = iter(self._meta.fields)
if not kwargs:
- # The ordering of the izip calls matter - izip throws StopIteration
+ # The ordering of the zip calls matter - zip throws StopIteration
# when an iter throws it. So if the first iter throws it, the second
# is *not* consumed. We rely on this, so don't change the order
# without changing the logic.
- for val, field in izip(args, fields_iter):
+ for val, field in zip(args, fields_iter):
setattr(self, field.attname, val)
else:
# Slower, kwargs-ready version.
- for val, field in izip(args, fields_iter):
+ for val, field in zip(args, fields_iter):
setattr(self, field.attname, val)
kwargs.pop(field.name, None)
# Maintain compatibility with existing calls.
View
6 django/db/models/sql/compiler.py
@@ -1,4 +1,4 @@
-from itertools import izip
+from future_builtins import zip
from django.core.exceptions import FieldError
from django.db import transaction
@@ -882,7 +882,7 @@ def as_sql(self):
placeholders = [["%s"] * len(fields)]
else:
placeholders = [
- [self.placeholder(field, v) for field, v in izip(fields, val)]
+ [self.placeholder(field, v) for field, v in zip(fields, val)]
for val in values
]
if self.return_id and self.connection.features.can_return_id_from_insert:
@@ -899,7 +899,7 @@ def as_sql(self):
else:
return [
(" ".join(result + ["VALUES (%s)" % ", ".join(p)]), vals)
- for p, vals in izip(placeholders, params)
+ for p, vals in zip(placeholders, params)
]
def execute_sql(self, return_id=False):
Please sign in to comment.
Something went wrong with that request. Please try again.