Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#22871 closed enhancement (fixed)

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

Reported by: chapoton Owned by:
Priority: major Milestone: sage-8.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 chapoton)

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 chapoton

  • Branch set to u/chapoton/22871
  • Commit set to 3dee3a348d2563baeedfd788d35c1c1505f25e49
  • Status changed from new to needs_review

New commits:

3dee3a3use six integer_types in some isinstance

comment:2 Changed 4 years ago by chapoton

  • Cc tscrim jdemeyer aapitzsch jmantysalo added
  • Description modified (diff)

comment:3 Changed 4 years ago by git

  • Commit changed from 3dee3a348d2563baeedfd788d35c1c1505f25e49 to 038d4064b754844c223de95359500a0f1c2558a7

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

038d406trac 22871 typo

comment:4 Changed 4 years ago by git

  • Commit changed from 038d4064b754844c223de95359500a0f1c2558a7 to 088dcebf40062e9ae31b5f2e03905562b39c3902

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

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

comment:5 Changed 4 years ago by chapoton

  • Description modified (diff)

comment:6 Changed 4 years ago by git

  • Commit changed from 088dcebf40062e9ae31b5f2e03905562b39c3902 to 056118330e47a260ffb9610a8570648793fbe940

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

0561183trac 22871 two more uses of integer_types

comment:7 Changed 4 years ago by git

  • Commit changed from 056118330e47a260ffb9610a8570648793fbe940 to 8c223ad6000c03ebbf7f66f680854cd6af38a79e

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

8c223adtrac 22871 typo

comment:8 Changed 4 years ago by jhpalmieri

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 S-Boxes and Their Algebraic Representations 
    33"""
    44from __future__ import print_function, division
    55from six.moves import range
     6from six import integer_types
    67
    78from sage.combinat.integer_vector import IntegerVectors
    89from 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): 
    7878        """
    7979        MonoidElement.__init__(self, F)
    8080        n = F.ngens()
    81         if isinstance(x, integer_types, + (Integer,)) and x == 1:
     81        if isinstance(x, integer_types + (Integer,)) and x == 1:
    8282            self._element_vector = tuple([0]*n)
    8383        elif isinstance(x, (list, tuple)):
    8484            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): 
    8383        if isinstance(x, list):
    8484            if check:
    8585                for b in x:
    86                     if not isinstance(b, integer_types + (Intger,)):
     86                    if not isinstance(b, integer_types + (Integer,)):
    8787                        raise TypeError(
    8888                            "x (= %s) must be a list of integers." % x)
    8989            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): 
    421421
    422422        if R is None:
    423423            R = Sequence(x).universe()
    424             if R in (rings.ZZ, integer_types):
     424            if R in (rings.ZZ,) + integer_types:
    425425                R = rings.QQ
    426426
    427427        return (R, tuple(R(a) for a in x)), kwds

comment:9 Changed 4 years ago by jhpalmieri

  • Branch changed from u/chapoton/22871 to u/jhpalmieri/22871

comment:10 Changed 4 years ago by chapoton

  • Commit changed from 8c223ad6000c03ebbf7f66f680854cd6af38a79e to 09cae0a9e5abe1d5836db97ed9854e6e2f9c19f5

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

comment:11 Changed 4 years ago by chapoton

  • 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:

7b44396trac 22871 two more changes with integer_types

comment:12 Changed 4 years ago by chapoton

  • Summary changed from py3: use six.integer_types to py3: use six.integer_types (step 1/2)

comment:13 Changed 4 years ago by jhpalmieri

  • 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 chapoton

(see the sequel in #22879)

comment:15 Changed 4 years ago by chapoton

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.

Last edited 4 years ago by chapoton (previous) (diff)

comment:16 Changed 4 years ago by vbraun

  • 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 jdemeyer

  • Commit 7b44396a828cebbb5e414a9c23329f6d74448564 deleted
  • Reviewers changed from John Pamieri to John Palmieri
Note: See TracTickets for help on using tickets.