Opened 5 years ago

Last modified 20 months ago

#16085 closed defect

Python 3 preparation: Py2 vs. Py3 value of type() in doctests — at Version 8

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

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:

  • 73 <type 'int'>
  • 65 <type 'tuple'>
  • 43 <type 'object'>
  • 35 <type 'float'>
  • 32 <type 'str'> #22060
  • 22 <type 'dict'>
  • 18 <type 'generator'>
  • 9 <type 'function'>
  • 9 <type 'bool'>
  • 8 <type 'long'>
  • 5 <type 'instance'>
  • 5 <type 'complex'>
  • 4 <type 'frozenset'>
  • 3 <type 'type'>
  • 1 <type 'set'>

and in src/doc:

  • 19 <type 'str'>
  • 18 <type 'list'>
  • 14 <type 'tuple'>
  • 14 <type 'function'>
  • 8 <type 'int'>
  • 8 <type 'instancemethod'>
  • 8 <type 'dict'>
  • 6 <type 'float'>

Change History (8)

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)
Note: See TracTickets for help on using tickets.