Opened 7 years ago
Closed 4 years ago
#15994 closed enhancement (fixed)
Python 3 preparation: Change for removed members of types module
Reported by: | wluebbe | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-8.0 |
Component: | python3 | Keywords: | python3 |
Cc: | Merged in: | ||
Authors: | Jeroen Demeyer | Reviewers: | Frédéric Chapoton |
Report Upstream: | N/A | Work issues: | |
Branch: | 925b5a5 (Commits) | Commit: | 925b5a585d6f053849ffa16a0d5329eedec015ad |
Dependencies: | Stopgaps: |
Description
Some members were removed from the types
module in Python 3.
Replace the deprecated members by their modern equivalents.
Changes according to lib2to3/fixes/fix_types.py
:
'BooleanType' : 'bool', 'BufferType' : 'memoryview', 'ClassType' : 'type', 'ComplexType' : 'complex', 'DictType': 'dict', 'DictionaryType' : 'dict', 'EllipsisType' : 'type(Ellipsis)', 'FloatType': 'float', 'IntType': 'int', 'ListType': 'list', 'LongType': 'int', 'ObjectType' : 'object', 'NoneType': 'type(None)', 'NotImplementedType' : 'type(NotImplemented)', 'SliceType' : 'slice', 'StringType': 'bytes', # XXX ? 'StringTypes' : 'str', # XXX ? 'TupleType': 'tuple', 'TypeType' : 'type', 'UnicodeType': 'str', 'XRangeType' : 'range',
This ticket is tracked as a dependency of meta-ticket ticket:15980.
Attachments (1)
Change History (30)
Changed 7 years ago by
comment:1 Changed 7 years ago by
- Branch set to u/wluebbe/ticket/15994
- Commit set to f741ed21b0019f1d6e1119bdd2038a337f7174cc
The generated code leads to 8 doctest failures, all of them in src/sage/misc/explain_pickle.py
.
For details see the attachment.
New commits:
f741ed2 | changes generated by 2to3 tool (types) for Python 3
|
comment:2 Changed 7 years ago by
There is a Python ticket 2to3 doesn't convert 'types.InstanceType' to 'object'.
The recommendation seems to be
or add try: from types import InstanceType except ImportError: InstanceType = object to the top of the module; this would then work for both 2.x and 3.x (assuming that replacing InstanceType with object is actually correct in the code in question).
comment:3 Changed 7 years ago by
- Status changed from new to needs_review
Status updated to allow "needs work" ...
comment:4 Changed 7 years ago by
- Status changed from needs_review to needs_work
It needs work on the failing doctests.
The failing tests seem all to be concerned with old style classes. Python 3 has only new style classes.
Maybe there are no more old style classes in Sage - and those tests might be removed??
Is there somebody familiar with src/sage/misc/explain_pickle.py
who can comment?
comment:5 Changed 7 years ago by
There are plenty of old style classes in Sage. A lot of the codebase is ancient and has not received much attention in years. I don't know the module at all, so I can't really help here.
comment:6 Changed 7 years ago by
- Milestone changed from sage-6.2 to sage-6.3
comment:7 Changed 7 years ago by
- Milestone changed from sage-6.3 to sage-6.4
comment:8 Changed 5 years ago by
- Branch changed from u/wluebbe/ticket/15994 to public/15994
- Commit changed from f741ed21b0019f1d6e1119bdd2038a337f7174cc to 02b3dedb16ae9f770bc9b0bb88ef6664be58f68a
comment:9 Changed 5 years ago by
- Milestone changed from sage-6.4 to sage-7.2
comment:10 Changed 5 years ago by
- Status changed from needs_work to needs_review
I am temporarily putting this to needs review to see what are the errors now.
comment:11 Changed 5 years ago by
- Commit changed from 02b3dedb16ae9f770bc9b0bb88ef6664be58f68a to 50c9d97351049f66ac17ba52b8635428eef95418
Branch pushed to git repo; I updated commit sha1. New commits:
50c9d97 | trac #15994 changing doctests in explain_pickle
|
comment:12 Changed 5 years ago by
- Status changed from needs_review to needs_work
If somebody with expertise in pickles could have a look, that would be great.
comment:13 Changed 5 years ago by
- Component changed from distribution to python3
comment:14 Changed 5 years ago by
Let us split the "more easy" part of that in #20962.
comment:15 Changed 5 years ago by
- Milestone changed from sage-7.2 to sage-7.3
comment:16 Changed 5 years ago by
There remains only a very annoying issue with pickle and old-style classes.
comment:17 Changed 5 years ago by
some work on that in #21230
comment:18 Changed 5 years ago by
- Milestone changed from sage-7.3 to sage-7.4
comment:19 Changed 5 years ago by
I'm willing to have a look at the explain_pickle.py
thing (but not right now).
comment:20 Changed 4 years ago by
remains one XRangeType
and several ClassType
comment:21 Changed 4 years ago by
XRangeType is handled in #21867
comment:22 Changed 4 years ago by
- Milestone changed from sage-7.4 to sage-7.6
comment:23 Changed 4 years ago by
- Branch public/15994 deleted
- Commit 50c9d97351049f66ac17ba52b8635428eef95418 deleted
comment:24 Changed 4 years ago by
one instance of ClassType? is handled in #22918
there remains only the 2 ClassType? in explain_pickle.
comment:25 Changed 4 years ago by
- Milestone changed from sage-7.6 to sage-8.0
comment:26 Changed 4 years ago by
- Branch set to u/jdemeyer/python_3_preparation__change_for_removed_members_of_types_module
comment:27 Changed 4 years ago by
- Commit set to 925b5a585d6f053849ffa16a0d5329eedec015ad
- Status changed from needs_work to needs_review
This one was actually easy: you just need to pretend that isinstance(foo, types.ClassType)
is always False
on Python 3.
Note that I also did some cleanup, including adding an unrelated doctest. I hope that is acceptable.
New commits:
925b5a5 | Do not require types.ClassType
|
comment:28 Changed 4 years ago by
- Reviewers set to Frédéric Chapoton
- Status changed from needs_review to positive_review
ok,let it be. Thanks
comment:29 Changed 4 years ago by
- Branch changed from u/jdemeyer/python_3_preparation__change_for_removed_members_of_types_module to 925b5a585d6f053849ffa16a0d5329eedec015ad
- Resolution set to fixed
- Status changed from positive_review to closed
8 failed doctests in src/sage/misc/explain_pickle.py.