diff options
author | Petr Viktorin <pviktori@redhat.com> | 2015-08-12 12:07:52 +0200 |
---|---|---|
committer | Jan Cholasta <jcholast@redhat.com> | 2015-09-01 11:42:01 +0200 |
commit | fbacc26a6a8b92f4b3570c411b186ab86cbcc1b1 (patch) | |
tree | 0216c07e276d4441e834a964516d2880858d4650 /ipalib | |
parent | c27cb295a586cdc1f1cc9b933829db471e5100ed (diff) | |
download | freeipa-fbacc26a6a8b92f4b3570c411b186ab86cbcc1b1.tar.gz freeipa-fbacc26a6a8b92f4b3570c411b186ab86cbcc1b1.tar.xz freeipa-fbacc26a6a8b92f4b3570c411b186ab86cbcc1b1.zip |
Use six.integer_types instead of (long, int)
Reviewed-By: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Diffstat (limited to 'ipalib')
-rw-r--r-- | ipalib/parameters.py | 16 | ||||
-rw-r--r-- | ipalib/rpc.py | 4 | ||||
-rw-r--r-- | ipalib/util.py | 2 |
3 files changed, 11 insertions, 11 deletions
diff --git a/ipalib/parameters.py b/ipalib/parameters.py index 175adefb8..b81e515c3 100644 --- a/ipalib/parameters.py +++ b/ipalib/parameters.py @@ -1031,7 +1031,7 @@ class Number(Param): """ if type(value) in self.allowed_types: return value - if type(value) in (unicode, int, long, float): + if type(value) in (unicode, float) + six.integer_types: try: return self.type(value) except ValueError: @@ -1050,12 +1050,12 @@ class Int(Number): """ type = int - allowed_types = int, long + allowed_types = six.integer_types type_error = _('must be an integer') kwargs = Param.kwargs + ( - ('minvalue', (int, long), int(MININT)), - ('maxvalue', (int, long), int(MAXINT)), + ('minvalue', six.integer_types, int(MININT)), + ('maxvalue', six.integer_types, int(MAXINT)), ) @staticmethod @@ -1097,7 +1097,7 @@ class Int(Number): """ Check min constraint. """ - assert type(value) in (int, long) + assert type(value) in six.integer_types if value < self.minvalue: return _('must be at least %(minvalue)d') % dict( minvalue=self.minvalue, @@ -1107,7 +1107,7 @@ class Int(Number): """ Check max constraint. """ - assert type(value) in (int, long) + assert type(value) in six.integer_types if value > self.maxvalue: return _('can be at most %(maxvalue)d') % dict( maxvalue=self.maxvalue, @@ -1413,7 +1413,7 @@ class Str(Data): """ if type(value) in self.allowed_types: return value - if type(value) in (int, long, float, decimal.Decimal): + if type(value) in (float, decimal.Decimal) + six.integer_types: return self.type(value) if type(value) in (tuple, list): raise ConversionError(name=self.name, index=index, @@ -1567,7 +1567,7 @@ class IntEnum(Enum): """ type = int - allowed_types = int, long + allowed_types = six.integer_types type_error = Int.type_error def _convert_scalar(self, value, index=None): diff --git a/ipalib/rpc.py b/ipalib/rpc.py index b76d27885..dcbfafe05 100644 --- a/ipalib/rpc.py +++ b/ipalib/rpc.py @@ -166,7 +166,7 @@ def xml_wrap(value, version): if type(value) is Decimal: # transfer Decimal as a string return unicode(value) - if isinstance(value, (int, long)) and (value < MININT or value > MAXINT): + if isinstance(value, six.integer_types) and (value < MININT or value > MAXINT): return unicode(value) if isinstance(value, DN): return str(value) @@ -184,7 +184,7 @@ def xml_wrap(value, version): else: return unicode(value) - assert type(value) in (unicode, int, long, float, bool, NoneType) + assert type(value) in (unicode, float, bool, NoneType) + six.integer_types return value diff --git a/ipalib/util.py b/ipalib/util.py index 3b8e59216..3cd23c96e 100644 --- a/ipalib/util.py +++ b/ipalib/util.py @@ -52,7 +52,7 @@ def json_serialize(obj): return [json_serialize(o) for o in obj] if isinstance(obj, dict): return {k: json_serialize(v) for (k, v) in obj.items()} - if isinstance(obj, (bool, float, int, long, unicode, NoneType)): + if isinstance(obj, (bool, float, unicode, NoneType, six.integer_types)): return obj if isinstance(obj, str): return obj.decode('utf-8') |