[py3k] six.integer_types
authorRémi Cardona <remi.cardona@logilab.fr>
Thu, 17 Sep 2015 09:52:06 +0200
changeset 10613 8d9fe02387e3
parent 10612 84468b90e9c1
child 10614 57dfde80df11
[py3k] six.integer_types
dataimport/pgstore.py
entity.py
predicates.py
server/querier.py
server/test/unittest_querier.py
uilib.py
--- a/dataimport/pgstore.py	Mon Sep 14 16:03:07 2015 +0200
+++ b/dataimport/pgstore.py	Thu Sep 17 09:52:06 2015 +0200
@@ -27,7 +27,7 @@
 from collections import defaultdict
 from base64 import b64encode
 
-from six import string_types
+from six import string_types, integer_types
 from six.moves import cPickle as pickle, range
 
 from cubicweb.utils import make_uid
@@ -166,7 +166,7 @@
 # (types, converter) list.
 _COPYFROM_BUFFER_CONVERTERS = [
     (type(None), _copyfrom_buffer_convert_None),
-    ((long, int, float), _copyfrom_buffer_convert_number),
+    (integer_types + (float,), _copyfrom_buffer_convert_number),
     (string_types, _copyfrom_buffer_convert_string),
     (datetime, _copyfrom_buffer_convert_datetime),
     (date, _copyfrom_buffer_convert_date),
--- a/entity.py	Mon Sep 14 16:03:07 2015 +0200
+++ b/entity.py	Thu Sep 17 09:52:06 2015 +0200
@@ -22,7 +22,7 @@
 from warnings import warn
 from functools import partial
 
-from six import string_types
+from six import string_types, integer_types
 from six.moves import range
 
 from logilab.common.decorators import cached
@@ -548,12 +548,12 @@
         raise NotImplementedError('comparison not implemented for %s' % self.__class__)
 
     def __eq__(self, other):
-        if isinstance(self.eid, (int, long)):
+        if isinstance(self.eid, integer_types):
             return self.eid == other.eid
         return self is other
 
     def __hash__(self):
-        if isinstance(self.eid, (int, long)):
+        if isinstance(self.eid, integer_types):
             return self.eid
         return super(Entity, self).__hash__()
 
--- a/predicates.py	Mon Sep 14 16:03:07 2015 +0200
+++ b/predicates.py	Thu Sep 17 09:52:06 2015 +0200
@@ -24,7 +24,7 @@
 from warnings import warn
 from operator import eq
 
-from six import string_types
+from six import string_types, integer_types
 from six.moves import range
 
 from logilab.common.deprecation import deprecated
@@ -674,7 +674,7 @@
             score = scorefunc(*args, **kwargs)
             if not score:
                 return 0
-            if isinstance(score, (int, long)):
+            if isinstance(score, integer_types):
                 return score
             return 1
         self.score_entity = intscore
--- a/server/querier.py	Mon Sep 14 16:03:07 2015 +0200
+++ b/server/querier.py	Thu Sep 17 09:52:06 2015 +0200
@@ -24,7 +24,7 @@
 
 from itertools import repeat
 
-from six import string_types
+from six import string_types, integer_types
 from six.moves import range
 
 from rql import RQLSyntaxError, CoercionError
@@ -453,11 +453,11 @@
             # if a string is given into args instead of an int, we get it here
             if isinstance(subj, string_types):
                 subj = int(subj)
-            elif not isinstance(subj, (int, long)):
+            elif not isinstance(subj, integer_types):
                 subj = subj.entity.eid
             if isinstance(obj, string_types):
                 obj = int(obj)
-            elif not isinstance(obj, (int, long)):
+            elif not isinstance(obj, integer_types):
                 obj = obj.entity.eid
             if repo.schema.rschema(rtype).inlined:
                 if subj not in edited_entities:
--- a/server/test/unittest_querier.py	Mon Sep 14 16:03:07 2015 +0200
+++ b/server/test/unittest_querier.py	Thu Sep 17 09:52:06 2015 +0200
@@ -21,7 +21,7 @@
 
 from datetime import date, datetime, timedelta, tzinfo
 
-from six import PY2
+from six import PY2, integer_types
 from logilab.common.testlib import TestCase, unittest_main
 from rql import BadRQLQuery, RQLSyntaxError
 
@@ -320,7 +320,7 @@
     def test_typed_eid(self):
         # should return an empty result set
         rset = self.qexecute('Any X WHERE X eid %(x)s', {'x': '1'})
-        self.assertIsInstance(rset[0][0], (int, long))
+        self.assertIsInstance(rset[0][0], integer_types)
 
     def test_bytes_storage(self):
         feid = self.qexecute('INSERT File X: X data_name "foo.pdf", '
--- a/uilib.py	Mon Sep 14 16:03:07 2015 +0200
+++ b/uilib.py	Thu Sep 17 09:52:06 2015 +0200
@@ -28,7 +28,7 @@
 import re
 from StringIO import StringIO
 
-from six import string_types
+from six import string_types, integer_types
 
 from logilab.mtconverter import xml_escape, html_unescape
 from logilab.common.date import ustrftime
@@ -94,7 +94,7 @@
 _('%d seconds')
 
 def print_timedelta(value, req, props, displaytime=True):
-    if isinstance(value, (int, long)):
+    if isinstance(value, integer_types):
         # `date - date`, unlike `datetime - datetime` gives an int
         # (number of days), not a timedelta
         # XXX should rql be fixed to return Int instead of Interval in