#22871 closed enhancement (fixed)
py3: use six.integer_types (step 1/2)
Reported by:  chapoton  Owned by:  

Priority:  major  Milestone:  sage8.0 
Component:  python3  Keywords:  
Cc:  tscrim, jdemeyer, aapitzsch, jmantysalo  Merged in:  
Authors:  Frédéric Chapoton  Reviewers:  John Palmieri 
Report Upstream:  N/A  Work issues:  
Branch:  7b44396 (Commits)  Commit:  
Dependencies:  Stopgaps: 
Description (last modified by )
in some calls to isinstance (inside .py files)
part of #16072
There will remain to handle the "rings" and "modular" folders.
Also "src/sage/misc/sage_input.py" will need separate care.
Change History (17)
comment:1 Changed 4 years ago by
 Branch set to u/chapoton/22871
 Commit set to 3dee3a348d2563baeedfd788d35c1c1505f25e49
 Status changed from new to needs_review
comment:2 Changed 4 years ago by
 Cc tscrim jdemeyer aapitzsch jmantysalo added
 Description modified (diff)
comment:3 Changed 4 years ago by
 Commit changed from 3dee3a348d2563baeedfd788d35c1c1505f25e49 to 038d4064b754844c223de95359500a0f1c2558a7
Branch pushed to git repo; I updated commit sha1. New commits:
038d406  trac 22871 typo

comment:4 Changed 4 years ago by
 Commit changed from 038d4064b754844c223de95359500a0f1c2558a7 to 088dcebf40062e9ae31b5f2e03905562b39c3902
Branch pushed to git repo; I updated commit sha1. New commits:
088dceb  py3 (trac 22871) more cases of integer_types (outside rings and modular)

comment:5 Changed 4 years ago by
 Description modified (diff)
comment:6 Changed 4 years ago by
 Commit changed from 088dcebf40062e9ae31b5f2e03905562b39c3902 to 056118330e47a260ffb9610a8570648793fbe940
Branch pushed to git repo; I updated commit sha1. New commits:
0561183  trac 22871 two more uses of integer_types

comment:7 Changed 4 years ago by
 Commit changed from 056118330e47a260ffb9610a8570648793fbe940 to 8c223ad6000c03ebbf7f66f680854cd6af38a79e
Branch pushed to git repo; I updated commit sha1. New commits:
8c223ad  trac 22871 typo

comment:8 Changed 4 years ago by
After I made the following changes, doctests passed:

src/sage/crypto/mq/sbox.py
diff git a/src/sage/crypto/mq/sbox.py b/src/sage/crypto/mq/sbox.py index 2ca7a87ce4..fe83e4f36c 100644
a b SBoxes and Their Algebraic Representations 3 3 """ 4 4 from __future__ import print_function, division 5 5 from six.moves import range 6 from six import integer_types 6 7 7 8 from sage.combinat.integer_vector import IntegerVectors 8 9 from sage.crypto.boolean_function import BooleanFunction 
src/sage/monoids/free_abelian_monoid_element.py
diff git a/src/sage/monoids/free_abelian_monoid_element.py b/src/sage/monoids/free_abelian_monoid_element.py index e04b295483..0c7d859068 100644
a b class FreeAbelianMonoidElement(MonoidElement): 78 78 """ 79 79 MonoidElement.__init__(self, F) 80 80 n = F.ngens() 81 if isinstance(x, integer_types ,+ (Integer,)) and x == 1:81 if isinstance(x, integer_types + (Integer,)) and x == 1: 82 82 self._element_vector = tuple([0]*n) 83 83 elif isinstance(x, (list, tuple)): 84 84 if len(x) != n: 
src/sage/monoids/string_monoid_element.py
diff git a/src/sage/monoids/string_monoid_element.py b/src/sage/monoids/string_monoid_element.py index 503b56f8c0..1173827469 100644
a b class StringMonoidElement(FreeMonoidElement): 83 83 if isinstance(x, list): 84 84 if check: 85 85 for b in x: 86 if not isinstance(b, integer_types + (Int ger,)):86 if not isinstance(b, integer_types + (Integer,)): 87 87 raise TypeError( 88 88 "x (= %s) must be a list of integers." % x) 89 89 self._element_list = list(x) # make copy 
src/sage/schemes/elliptic_curves/constructor.py
diff git a/src/sage/schemes/elliptic_curves/constructor.py b/src/sage/schemes/elliptic_curves/constructor.py index c6375ad632..c2f38de010 100644
a b class EllipticCurveFactory(UniqueFactory): 421 421 422 422 if R is None: 423 423 R = Sequence(x).universe() 424 if R in (rings.ZZ, integer_types):424 if R in (rings.ZZ,) + integer_types: 425 425 R = rings.QQ 426 426 427 427 return (R, tuple(R(a) for a in x)), kwds
comment:9 Changed 4 years ago by
 Branch changed from u/chapoton/22871 to u/jhpalmieri/22871
comment:10 Changed 4 years ago by
 Commit changed from 8c223ad6000c03ebbf7f66f680854cd6af38a79e to 09cae0a9e5abe1d5836db97ed9854e6e2f9c19f5
Thank you. It was all handmade, I had no time to compile sage, and I was tired..
New commits:
09cae0a  trac 22871 fix some typos and omissions

comment:11 Changed 4 years ago by
 Branch changed from u/jhpalmieri/22871 to u/chapoton/22871
 Commit changed from 09cae0a9e5abe1d5836db97ed9854e6e2f9c19f5 to 7b44396a828cebbb5e414a9c23329f6d74448564
I just found two other places needing corrections
New commits:
7b44396  trac 22871 two more changes with integer_types

comment:12 Changed 4 years ago by
 Summary changed from py3: use six.integer_types to py3: use six.integer_types (step 1/2)
comment:13 Changed 4 years ago by
 Reviewers set to John Pamieri
 Status changed from needs_review to positive_review
Okay, looks good. I haven't searched to see if this is every instance, but we can fix more on another ticket if necessary.
comment:14 Changed 4 years ago by
(see the sequel in #22879)
comment:15 Changed 4 years ago by
Thanks, John.
After this and #22879, there remains at least
src/sage/arith/misc.py: if U is ZZ or U is int or U is long:# ZZ.has_coerce_map_from(U):
and
src/sage/rings/number_field/order.py: return R is ZZ or R is int or R is long
to be done later in another ticket.
comment:16 Changed 4 years ago by
 Branch changed from u/chapoton/22871 to 7b44396a828cebbb5e414a9c23329f6d74448564
 Resolution set to fixed
 Status changed from positive_review to closed
comment:17 Changed 3 years ago by
 Commit 7b44396a828cebbb5e414a9c23329f6d74448564 deleted
 Reviewers changed from John Pamieri to John Palmieri
New commits:
use six integer_types in some isinstance