Skip to content
This repository has been archived by the owner on Jun 13, 2020. It is now read-only.

Commit

Permalink
Replaced types.NoneType occurrences
Browse files Browse the repository at this point in the history
In Python 3, types.NoneType is no more available.
  • Loading branch information
claudep committed May 23, 2012
1 parent 0df4593 commit 817535d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions 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):
Expand All @@ -26,7 +26,7 @@ def _set_ptr(self, ptr):
# 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')
Expand Down
4 changes: 2 additions & 2 deletions 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
Expand Down Expand Up @@ -41,7 +41,7 @@ def _get_ptr(self):
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')
Expand Down
5 changes: 2 additions & 3 deletions django/utils/encoding.py
@@ -1,4 +1,3 @@
import types
import urllib
import locale
import datetime
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 817535d

Please sign in to comment.