From b054609dbf7c773f4dcbecda078a140764b8a690 Mon Sep 17 00:00:00 2001
From: bowlofkashi <bowlofkashi@bestmail.us>
Date: Sat, 21 Jun 2014 15:04:45 -0500
Subject: [PATCH 1/2] Change occurrences of isinstance(..., int) to
isinstance(..., six.integer_types)
---
django/contrib/admin/checks.py | 10 +++++-----
django/contrib/admin/options.py | 2 +-
django/contrib/gis/gdal/datasource.py | 2 +-
django/contrib/gis/gdal/driver.py | 2 +-
django/contrib/gis/gdal/geomtype.py | 4 ++--
django/contrib/gis/gdal/srs.py | 2 +-
django/contrib/gis/geos/geometry.py | 2 +-
django/contrib/gis/utils/layermapping.py | 4 ++--
django/contrib/gis/utils/wkt.py | 2 +-
django/core/checks/messages.py | 2 +-
django/db/models/sql/compiler.py | 2 +-
django/utils/dictconfig.py | 2 +-
django/utils/numberformat.py | 2 +-
django/utils/translation/__init__.py | 2 +-
django/views/i18n.py | 2 +-
15 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/django/contrib/admin/checks.py b/django/contrib/admin/checks.py
index 3350625..04a2c00 100644
a
|
b
|
class ModelAdminChecks(BaseModelAdminChecks):
|
735 | 735 | def _check_list_per_page(self, cls, model): |
736 | 736 | """ Check that list_per_page is an integer. """ |
737 | 737 | |
738 | | if not isinstance(cls.list_per_page, int): |
| 738 | if not isinstance(cls.list_per_page, six.integer_types): |
739 | 739 | return must_be('an integer', option='list_per_page', obj=cls, id='admin.E118') |
740 | 740 | else: |
741 | 741 | return [] |
… |
… |
class ModelAdminChecks(BaseModelAdminChecks):
|
743 | 743 | def _check_list_max_show_all(self, cls, model): |
744 | 744 | """ Check that list_max_show_all is an integer. """ |
745 | 745 | |
746 | | if not isinstance(cls.list_max_show_all, int): |
| 746 | if not isinstance(cls.list_max_show_all, six.integer_types): |
747 | 747 | return must_be('an integer', option='list_max_show_all', obj=cls, id='admin.E119') |
748 | 748 | else: |
749 | 749 | return [] |
… |
… |
class InlineModelAdminChecks(BaseModelAdminChecks):
|
898 | 898 | def _check_extra(self, cls): |
899 | 899 | """ Check that extra is an integer. """ |
900 | 900 | |
901 | | if not isinstance(cls.extra, int): |
| 901 | if not isinstance(cls.extra, six.integer_types): |
902 | 902 | return must_be('an integer', option='extra', obj=cls, id='admin.E203') |
903 | 903 | else: |
904 | 904 | return [] |
… |
… |
class InlineModelAdminChecks(BaseModelAdminChecks):
|
908 | 908 | |
909 | 909 | if cls.max_num is None: |
910 | 910 | return [] |
911 | | elif not isinstance(cls.max_num, int): |
| 911 | elif not isinstance(cls.max_num, six.integer_types): |
912 | 912 | return must_be('an integer', option='max_num', obj=cls, id='admin.E204') |
913 | 913 | else: |
914 | 914 | return [] |
… |
… |
class InlineModelAdminChecks(BaseModelAdminChecks):
|
918 | 918 | |
919 | 919 | if cls.min_num is None: |
920 | 920 | return [] |
921 | | elif not isinstance(cls.min_num, int): |
| 921 | elif not isinstance(cls.min_num, six.integer_types): |
922 | 922 | return must_be('an integer', option='min_num', obj=cls, id='admin.E205') |
923 | 923 | else: |
924 | 924 | return [] |
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index e01cdd0..f027373 100644
a
|
b
|
class ModelAdmin(BaseModelAdmin):
|
993 | 993 | a string rather than the usual level number. |
994 | 994 | """ |
995 | 995 | |
996 | | if not isinstance(level, int): |
| 996 | if not isinstance(level, six.integer_types): |
997 | 997 | # attempt to get the level if passed a string |
998 | 998 | try: |
999 | 999 | level = getattr(messages.constants, level.upper()) |
diff --git a/django/contrib/gis/gdal/datasource.py b/django/contrib/gis/gdal/datasource.py
index 864f50a..71b52d7 100644
a
|
b
|
class DataSource(GDALBase):
|
110 | 110 | l = capi.get_layer_by_name(self.ptr, force_bytes(index)) |
111 | 111 | if not l: |
112 | 112 | raise OGRIndexError('invalid OGR Layer name given: "%s"' % index) |
113 | | elif isinstance(index, int): |
| 113 | elif isinstance(index, six.integer_types): |
114 | 114 | if index < 0 or index >= self.layer_count: |
115 | 115 | raise OGRIndexError('index out of range') |
116 | 116 | l = capi.get_layer(self._ptr, index) |
diff --git a/django/contrib/gis/gdal/driver.py b/django/contrib/gis/gdal/driver.py
index 58f736b..ca2ccde 100644
a
|
b
|
class Driver(GDALBase):
|
39 | 39 | |
40 | 40 | # Attempting to get the OGR driver by the string name. |
41 | 41 | dr = capi.get_driver_by_name(force_bytes(name)) |
42 | | elif isinstance(dr_input, int): |
| 42 | elif isinstance(dr_input, six.integer_types): |
43 | 43 | self._register() |
44 | 44 | dr = capi.get_driver(dr_input) |
45 | 45 | elif isinstance(dr_input, c_void_p): |
diff --git a/django/contrib/gis/gdal/geomtype.py b/django/contrib/gis/gdal/geomtype.py
index 1b5e079..d34bc22 100644
a
|
b
|
class OGRGeomType(object):
|
41 | 41 | num = self._str_types.get(type_input, None) |
42 | 42 | if num is None: |
43 | 43 | raise OGRException('Invalid OGR String Type "%s"' % type_input) |
44 | | elif isinstance(type_input, int): |
| 44 | elif isinstance(type_input, six.integer_types): |
45 | 45 | if type_input not in self._types: |
46 | 46 | raise OGRException('Invalid OGR Integer Type: %d' % type_input) |
47 | 47 | num = type_input |
… |
… |
class OGRGeomType(object):
|
64 | 64 | return self.num == other.num |
65 | 65 | elif isinstance(other, six.string_types): |
66 | 66 | return self.name.lower() == other.lower() |
67 | | elif isinstance(other, int): |
| 67 | elif isinstance(other, six.integer_types): |
68 | 68 | return self.num == other |
69 | 69 | else: |
70 | 70 | return False |
diff --git a/django/contrib/gis/gdal/srs.py b/django/contrib/gis/gdal/srs.py
index 65989f5..0316c44 100644
a
|
b
|
class SpatialReference(GDALBase):
|
138 | 138 | The attribute value for the given target node (e.g. 'PROJCS'). The index |
139 | 139 | keyword specifies an index of the child node to return. |
140 | 140 | """ |
141 | | if not isinstance(target, six.string_types) or not isinstance(index, int): |
| 141 | if not isinstance(target, six.string_types) or not isinstance(index, six.integer_types): |
142 | 142 | raise TypeError |
143 | 143 | return capi.get_attr_value(self.ptr, force_bytes(target), index) |
144 | 144 | |
diff --git a/django/contrib/gis/geos/geometry.py b/django/contrib/gis/geos/geometry.py
index 3cee800..0d27f34 100644
a
|
b
|
class GEOSGeometry(GEOSBase, ListMixin):
|
100 | 100 | def _post_init(self, srid): |
101 | 101 | "Helper routine for performing post-initialization setup." |
102 | 102 | # Setting the SRID, if given. |
103 | | if srid and isinstance(srid, int): |
| 103 | if srid and isinstance(srid, six.integer_types): |
104 | 104 | self.srid = srid |
105 | 105 | |
106 | 106 | # Setting the class type (e.g., Point, Polygon, etc.) |
diff --git a/django/contrib/gis/utils/layermapping.py b/django/contrib/gis/utils/layermapping.py
index ead2f17..cdce704 100644
a
|
b
|
class LayerMapping(object):
|
511 | 511 | |
512 | 512 | # Setting the progress interval, if requested. |
513 | 513 | if progress: |
514 | | if progress is True or not isinstance(progress, int): |
| 514 | if progress is True or not isinstance(progress, six.integer_types): |
515 | 515 | progress_interval = 1000 |
516 | 516 | else: |
517 | 517 | progress_interval = progress |
… |
… |
class LayerMapping(object):
|
589 | 589 | _save = self.transaction_decorator(_save) |
590 | 590 | |
591 | 591 | nfeat = self.layer.num_feat |
592 | | if step and isinstance(step, int) and step < nfeat: |
| 592 | if step and isinstance(step, six.integer_types) and step < nfeat: |
593 | 593 | # Incremental saving is requested at the given interval (step) |
594 | 594 | if default_range: |
595 | 595 | raise LayerMapError('The `step` keyword may not be used in conjunction with the `fid_range` keyword.') |
diff --git a/django/contrib/gis/utils/wkt.py b/django/contrib/gis/utils/wkt.py
index 65f2082..0457516 100644
a
|
b
|
def precision_wkt(geom, prec):
|
21 | 21 | If the precision is a string, it must be valid Python format string |
22 | 22 | (e.g., '%20.7f') -- thus, you should know what you're doing. |
23 | 23 | """ |
24 | | if isinstance(prec, int): |
| 24 | if isinstance(prec, six.integer_types): |
25 | 25 | num_fmt = '%%.%df' % prec |
26 | 26 | elif isinstance(prec, six.string_types): |
27 | 27 | num_fmt = prec |
diff --git a/django/core/checks/messages.py b/django/core/checks/messages.py
index 2528d11..c44a42c 100644
a
|
b
|
CRITICAL = 50
|
16 | 16 | class CheckMessage(object): |
17 | 17 | |
18 | 18 | def __init__(self, level, msg, hint=None, obj=None, id=None): |
19 | | assert isinstance(level, int), "The first argument should be level." |
| 19 | assert isinstance(level, six.integer_types), "The first argument should be level." |
20 | 20 | self.level = level |
21 | 21 | self.msg = msg |
22 | 22 | self.hint = hint |
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
index 59b31dc..513774f 100644
a
|
b
|
class SQLCompiler(object):
|
398 | 398 | if field == '?': |
399 | 399 | result.append(self.connection.ops.random_function_sql()) |
400 | 400 | continue |
401 | | if isinstance(field, int): |
| 401 | if isinstance(field, six.integer_types): |
402 | 402 | if field < 0: |
403 | 403 | order = desc |
404 | 404 | field = -field |
diff --git a/django/utils/dictconfig.py b/django/utils/dictconfig.py
index e2c7a43..b84ae1d 100644
a
|
b
|
try:
|
48 | 48 | from logging import _checkLevel |
49 | 49 | except ImportError: |
50 | 50 | def _checkLevel(level): |
51 | | if isinstance(level, int): |
| 51 | if isinstance(level, six.integer_types): |
52 | 52 | rv = level |
53 | 53 | elif str(level) == level: |
54 | 54 | if level not in logging._levelNames: |
diff --git a/django/utils/numberformat.py b/django/utils/numberformat.py
index 6a31237..4fa55f3 100644
a
|
b
|
def format(number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep='',
|
18 | 18 | use_grouping = use_grouping or force_grouping |
19 | 19 | use_grouping = use_grouping and grouping > 0 |
20 | 20 | # Make the common case fast |
21 | | if isinstance(number, int) and not use_grouping and not decimal_pos: |
| 21 | if isinstance(number, six.integer_types) and not use_grouping and not decimal_pos: |
22 | 22 | return mark_safe(six.text_type(number)) |
23 | 23 | # sign |
24 | 24 | sign = '' |
diff --git a/django/utils/translation/__init__.py b/django/utils/translation/__init__.py
index 6be6645..0318247 100644
a
|
b
|
pgettext_lazy = lazy(pgettext, six.text_type)
|
100 | 100 | |
101 | 101 | |
102 | 102 | def lazy_number(func, resultclass, number=None, **kwargs): |
103 | | if isinstance(number, int): |
| 103 | if isinstance(number, six.integer_types): |
104 | 104 | kwargs['number'] = number |
105 | 105 | proxy = lazy(func, resultclass)(**kwargs) |
106 | 106 | else: |
diff --git a/django/views/i18n.py b/django/views/i18n.py
index 7724a2e..2f2da91 100644
a
|
b
|
def get_formats():
|
62 | 62 | result[attr] = get_format(attr) |
63 | 63 | formats = {} |
64 | 64 | for k, v in result.items(): |
65 | | if isinstance(v, (six.string_types, int)): |
| 65 | if isinstance(v, (six.string_types, six.integer_types)): |
66 | 66 | formats[k] = smart_text(v) |
67 | 67 | elif isinstance(v, (tuple, list)): |
68 | 68 | formats[k] = [smart_text(value) for value in v] |
--
2.0.0
From 77174b14f90b765b37e11045882fa6e84830304f Mon Sep 17 00:00:00 2001
From: bowlofkashi <bowlofkashi@bestmail.us>
Date: Sat, 21 Jun 2014 15:30:17 -0500
Subject: [PATCH 2/2] Added missing 'from django.utils import six'
---
django/contrib/admin/checks.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/django/contrib/admin/checks.py b/django/contrib/admin/checks.py
index 04a2c00..6a8684c 100644
a
|
b
|
from django.db import models
|
9 | 9 | from django.db.models.fields import FieldDoesNotExist |
10 | 10 | from django.forms.models import BaseModelForm, _get_foreign_key, BaseModelFormSet |
11 | 11 | |
| 12 | from django.utils import six |
12 | 13 | |
13 | 14 | def check_admin_app(**kwargs): |
14 | 15 | from django.contrib.admin.sites import site |