Opened 8 years ago
Closed 4 years 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 )
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:
- 73 <type 'int'> #22233
- 65 <type 'tuple'> #22292
- 43 <type 'object'> #23105
- 35 <type 'float'> #22292
- 32 <type 'str'> #22060
- 22 <type 'dict'> #22292
- 18 <type 'generator'> #22292
- 9 <type 'function'> #22292
- 9 <type 'bool'> #22233
- 8 <type 'long'> !!! This one does no longer exists in Py3 !!!
- 5 <type 'instance'> #23073
- 5 <type 'complex'> #22233
- 4 <type 'frozenset'> #22233
- 3 <type 'type'> #22233
- 1 <type 'set'> #22233
and in src/doc (see #22114):
Change History (24)
comment:1 Changed 8 years ago by
- Description modified (diff)
comment:2 Changed 8 years ago by
- Milestone changed from sage-6.2 to sage-6.3
comment:3 Changed 8 years ago by
- Milestone changed from sage-6.3 to sage-6.4
comment:4 Changed 6 years ago by
- Component changed from distribution to python3
comment:5 Changed 6 years ago by
comment:6 Changed 6 years ago by
- Milestone changed from sage-6.4 to sage-7.5
comment:7 Changed 6 years ago by
- Description modified (diff)
- Type changed from enhancement to defect
comment:8 Changed 6 years ago by
- Description modified (diff)
comment:9 Changed 6 years ago by
- Description modified (diff)
comment:10 Changed 6 years ago by
- Description modified (diff)
comment:11 Changed 6 years ago by
- Description modified (diff)
comment:12 Changed 6 years ago by
- Milestone changed from sage-7.5 to sage-7.6
comment:13 Changed 6 years ago by
- Description modified (diff)
comment:14 Changed 6 years ago by
- Description modified (diff)
comment:15 Changed 6 years ago by
- Description modified (diff)
comment:17 Changed 5 years ago by
- Milestone changed from sage-7.6 to sage-8.0
comment:20 Changed 5 years ago by
next step in #23790
comment:21 Changed 5 years ago by
comment:22 Changed 5 years ago by
next in #24233
comment:23 Changed 4 years ago by
- 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 4 years ago by
- Resolution set to duplicate
- Status changed from needs_review to closed
Note: See
TracTickets for help on using
tickets.
see #21904 for list and #22060 for str