Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

py3: use six.integer_types (step 1/2) #22871

Closed
fchapoton opened this issue Apr 25, 2017 · 27 comments
Closed

py3: use six.integer_types (step 1/2) #22871

fchapoton opened this issue Apr 25, 2017 · 27 comments

Comments

@fchapoton
Copy link
Contributor

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.

CC: @tscrim @jdemeyer @a-andre @jm58660

Component: python3

Author: Frédéric Chapoton

Branch: 7b44396

Reviewer: John Palmieri

Issue created by migration from https://trac.sagemath.org/ticket/22871

@fchapoton fchapoton added this to the sage-8.0 milestone Apr 25, 2017
@fchapoton
Copy link
Contributor Author

Branch: u/chapoton/22871

@fchapoton
Copy link
Contributor Author

Commit: 3dee3a3

@fchapoton
Copy link
Contributor Author

New commits:

3dee3a3use six integer_types in some isinstance

@fchapoton

This comment has been minimized.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 25, 2017

Changed commit from 3dee3a3 to 038d406

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 25, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

038d406trac 22871 typo

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 25, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

088dcebpy3 (trac 22871) more cases of integer_types (outside rings and modular)

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 25, 2017

Changed commit from 038d406 to 088dceb

@fchapoton

This comment has been minimized.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 25, 2017

Changed commit from 088dceb to 0561183

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 25, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

0561183trac 22871 two more uses of integer_types

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 25, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

8c223adtrac 22871 typo

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 25, 2017

Changed commit from 0561183 to 8c223ad

@jhpalmieri
Copy link
Member

comment:8

After I made the following changes, doctests passed:

diff --git a/src/sage/crypto/mq/sbox.py b/src/sage/crypto/mq/sbox.py
index 2ca7a87ce4..fe83e4f36c 100644
--- a/src/sage/crypto/mq/sbox.py
+++ b/src/sage/crypto/mq/sbox.py
@@ -3,6 +3,7 @@ S-Boxes and Their Algebraic Representations
 """
 from __future__ import print_function, division
 from six.moves import range
+from six import integer_types
 
 from sage.combinat.integer_vector import IntegerVectors
 from sage.crypto.boolean_function import BooleanFunction
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/src/sage/monoids/free_abelian_monoid_element.py
+++ b/src/sage/monoids/free_abelian_monoid_element.py
@@ -78,7 +78,7 @@ class FreeAbelianMonoidElement(MonoidElement):
         """
         MonoidElement.__init__(self, F)
         n = F.ngens()
-        if isinstance(x, integer_types, + (Integer,)) and x == 1:
+        if isinstance(x, integer_types + (Integer,)) and x == 1:
             self._element_vector = tuple([0]*n)
         elif isinstance(x, (list, tuple)):
             if len(x) != n:
diff --git a/src/sage/monoids/string_monoid_element.py b/src/sage/monoids/string_monoid_element.py
index 503b56f8c0..1173827469 100644
--- a/src/sage/monoids/string_monoid_element.py
+++ b/src/sage/monoids/string_monoid_element.py
@@ -83,7 +83,7 @@ class StringMonoidElement(FreeMonoidElement):
         if isinstance(x, list):
             if check:
                 for b in x:
-                    if not isinstance(b, integer_types + (Intger,)):
+                    if not isinstance(b, integer_types + (Integer,)):
                         raise TypeError(
                             "x (= %s) must be a list of integers." % x)
             self._element_list = list(x) # make copy
diff --git a/src/sage/schemes/elliptic_curves/constructor.py b/src/sage/schemes/elliptic_curves/constructor.py
index c6375ad632..c2f38de010 100644
--- a/src/sage/schemes/elliptic_curves/constructor.py
+++ b/src/sage/schemes/elliptic_curves/constructor.py
@@ -421,7 +421,7 @@ class EllipticCurveFactory(UniqueFactory):
 
         if R is None:
             R = Sequence(x).universe()
-            if R in (rings.ZZ, integer_types):
+            if R in (rings.ZZ,) + integer_types:
                 R = rings.QQ
 
         return (R, tuple(R(a) for a in x)), kwds

@jhpalmieri
Copy link
Member

Changed branch from u/chapoton/22871 to u/jhpalmieri/22871

@fchapoton
Copy link
Contributor Author

Changed commit from 8c223ad to 09cae0a

@fchapoton
Copy link
Contributor Author

comment:10

Thank you. It was all hand-made, I had no time to compile sage, and I was tired..


New commits:

09cae0atrac 22871 fix some typos and omissions

@fchapoton
Copy link
Contributor Author

comment:11

I just found two other places needing corrections


New commits:

7b44396trac 22871 two more changes with integer_types

@fchapoton
Copy link
Contributor Author

Changed branch from u/jhpalmieri/22871 to u/chapoton/22871

@fchapoton
Copy link
Contributor Author

Changed commit from 09cae0a to 7b44396

@fchapoton fchapoton changed the title py3: use six.integer_types py3: use six.integer_types (step 1/2) Apr 26, 2017
@jhpalmieri
Copy link
Member

Reviewer: John Pamieri

@jhpalmieri
Copy link
Member

comment:13

Okay, looks good. I haven't searched to see if this is every instance, but we can fix more on another ticket if necessary.

@fchapoton
Copy link
Contributor Author

comment:14

(see the sequel in #22879)

@fchapoton
Copy link
Contributor Author

comment:15

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.

@vbraun
Copy link
Member

vbraun commented Apr 28, 2017

Changed branch from u/chapoton/22871 to 7b44396

@jdemeyer
Copy link

Changed commit from 7b44396 to none

@jdemeyer
Copy link

Changed reviewer from John Pamieri to John Palmieri

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants