diff options
| author | Claude Paroz <claude@2xlibre.net> | 2012-05-23 12:20:03 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2012-05-23 12:20:03 +0200 |
| commit | 817535d73e57d0930fd5294387fca17bc0257515 (patch) | |
| tree | 4c47efbfbfc4ecb215ebd16ae34fd26ac41316a0 | |
| parent | 0df4593f0edb8508eceff96ce5aebc59a073b506 (diff) | |
Replaced types.NoneType occurrences
In Python 3, types.NoneType is no more available.
| -rw-r--r-- | django/contrib/gis/gdal/base.py | 4 | ||||
| -rw-r--r-- | django/contrib/gis/geos/base.py | 4 | ||||
| -rw-r--r-- | django/utils/encoding.py | 5 |
3 files changed, 6 insertions, 7 deletions
diff --git a/django/contrib/gis/gdal/base.py b/django/contrib/gis/gdal/base.py index f9455c783a..36c03eb51e 100644 --- a/django/contrib/gis/gdal/base.py +++ b/django/contrib/gis/gdal/base.py @@ -1,5 +1,5 @@ from ctypes import c_void_p -from types import NoneType + from django.contrib.gis.gdal.error import GDALException class GDALBase(object): @@ -26,7 +26,7 @@ class GDALBase(object): # compatible type or None (NULL). if isinstance(ptr, (int, long)): self._ptr = self.ptr_type(ptr) - elif isinstance(ptr, (self.ptr_type, NoneType)): + elif ptr is None or isinstance(ptr, self.ptr_type): self._ptr = ptr else: raise TypeError('Incompatible pointer type') diff --git a/django/contrib/gis/geos/base.py b/django/contrib/gis/geos/base.py index b3012dd930..754bcce7ad 100644 --- a/django/contrib/gis/geos/base.py +++ b/django/contrib/gis/geos/base.py @@ -1,5 +1,5 @@ from ctypes import c_void_p -from types import NoneType + from django.contrib.gis.geos.error import GEOSException # Trying to import GDAL libraries, if available. Have to place in @@ -41,7 +41,7 @@ class GEOSBase(object): def _set_ptr(self, ptr): # Only allow the pointer to be set with pointers of the # compatible type or None (NULL). - if isinstance(ptr, (self.ptr_type, NoneType)): + if ptr is None or isinstance(ptr, self.ptr_type): self._ptr = ptr else: raise TypeError('Incompatible pointer type') diff --git a/django/utils/encoding.py b/django/utils/encoding.py index 9d9b8b8a2d..6b246ac59b 100644 --- a/django/utils/encoding.py +++ b/django/utils/encoding.py @@ -1,4 +1,3 @@ -import types import urllib import locale import datetime @@ -45,7 +44,7 @@ def is_protected_type(obj): force_unicode(strings_only=True). """ return isinstance(obj, ( - types.NoneType, + type(None), int, long, datetime.datetime, datetime.date, datetime.time, float, Decimal) @@ -107,7 +106,7 @@ def smart_str(s, encoding='utf-8', strings_only=False, errors='strict'): If strings_only is True, don't convert (some) non-string-like objects. """ - if strings_only and isinstance(s, (types.NoneType, int)): + if strings_only and (s is None or isinstance(s, int)): return s if isinstance(s, Promise): return unicode(s).encode(encoding, errors) |
