Opened 5 years ago

Closed 20 months ago

#16085 closed defect (duplicate)

Python 3 preparation: Py2 vs. Py3 value of type() in doctests

Reported by: wluebbe Owned by:
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: python3 Keywords: python3
Cc: embray Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by chapoton)

In Py2 we have

Python 2.7.5+ (default, Feb 27 2014, 19:37:08) 
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> b = True
>>> type(b)
<type 'bool'>

while in Py3

Python 3.3.2+ (default, Feb 28 2014, 00:52:16) 
[GCC 4.8.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> b = True
>>> type(b)
<class 'bool'>

The result may be unified with isinstance(). Py2

>>> isinstance(b, bool)
True

and Py3

>>> isinstance(b, bool)
True

A simpler way is to use "..." instead of "type" or "class". This can be automated using something like

grep -rl "<type 'list" src/sage/ | xargs sed -i "s/<type 'list/<... 'list/g"

About 161 py module are effected.

This ticket is tracked as a dependency of meta-ticket ticket:16052.

Using:

egrep -R --no-filename -o "<type '[a-z]*'>" src/sage | sort | uniq -c | sort -rn

to find what needs to be done in src/sage:

and in src/doc (see #22114):

Change History (24)

comment:1 Changed 5 years ago by wluebbe

  • Description modified (diff)

comment:2 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:3 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:4 Changed 3 years ago by jdemeyer

  • Component changed from distribution to python3

comment:5 Changed 3 years ago by chapoton

see #21904 for list and #22060 for str

comment:6 Changed 3 years ago by chapoton

  • Milestone changed from sage-6.4 to sage-7.5

comment:7 Changed 3 years ago by chapoton

  • Description modified (diff)
  • Type changed from enhancement to defect

comment:8 Changed 3 years ago by chapoton

  • Description modified (diff)

comment:9 Changed 3 years ago by chapoton

  • Description modified (diff)

comment:10 Changed 3 years ago by chapoton

  • Description modified (diff)

comment:11 Changed 3 years ago by chapoton

  • Description modified (diff)

comment:12 Changed 3 years ago by chapoton

  • Milestone changed from sage-7.5 to sage-7.6

comment:13 Changed 3 years ago by chapoton

  • Description modified (diff)

comment:14 Changed 3 years ago by chapoton

  • Description modified (diff)

comment:15 Changed 3 years ago by chapoton

  • Description modified (diff)

comment:16 Changed 3 years ago by chapoton

  • Description modified (diff)

another step in #22292

comment:17 Changed 2 years ago by chapoton

  • Milestone changed from sage-7.6 to sage-8.0

comment:18 Changed 2 years ago by chapoton

  • Description modified (diff)

next step in #23073

comment:19 Changed 2 years ago by chapoton

  • Description modified (diff)

next step in #23105

comment:20 Changed 2 years ago by chapoton

next step in #23790

comment:21 Changed 23 months ago by chapoton

next steps in #24228 and #24229 and #24230 for start

Last edited 23 months ago by chapoton (previous) (diff)

comment:22 Changed 22 months ago by chapoton

next in #24233

comment:23 Changed 20 months ago by chapoton

  • Cc embray added
  • Milestone changed from sage-8.0 to sage-duplicate/invalid/wontfix
  • Status changed from new to needs_review

Erik, can we close this one, after what you have done to the doctest framework in #24258 ?

comment:24 Changed 20 months ago by jdemeyer

  • Resolution set to duplicate
  • Status changed from needs_review to closed
Note: See TracTickets for help on using tickets.