New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
preparsing print into python3 format #23674
Comments
comment:1
I don't think we should go that way. It should not be the goal of Sage to do that. Just use the Python 3 syntax in your own code, possibly with |
comment:2
I understand your point of view, however, with that approach, a lot of homemade code will get broken whenever we do the switch because of a print. Just consider the case of someone running a long term computation and at the end, it will fail because the user tried to print the result. However, his code run totally fine in the previous version of sage. |
Changed keywords from none to days88 |
comment:4
In my mind, the idea is the following. At some point (hopefully, but this may never happen given the amount of remaining work and the sparsity of workers) there will be a release of sage working and passing all tests with python3. At this point, development of sage for python2 will stop. Users will have the choice either to continue using the "old python2 sage" or to switch to the "new python3 sage". This will imply that they need to refresh their code, and this will be advertised LOUDLY. Transition to python3 is a pain, and we cannot avoid to impose this pain to our users. |
comment:5
Another potential issue could be pre-made notebooks for educational purposes that aren't necessarily being actively maintained. I think there are lots of people using Sage that won't be reached without deprecation warnings in the code itself no matter how loudly we advertise. |
comment:6
Replying to @edgarcosta:
You should never do a long term computation without testing small cases first. If you test your own code properly, what you describe shouldn't happen. Besides, there are many more ways how a long term computation could break. |
comment:7
I agree an alternative is to deprecate the
just before we switch to python3. |
comment:8
Replying to @edgarcosta:
Or well before. |
comment:9
I just got pointed to this ticket. What's the current status? I think it's a real problem if existing textbooks and student assignments (used year after year for teaching) will no longer work because of that change. IMHO it would be ideal to let the preparser understand old print statements. I don't care if there is a deprecation warning or not, just that those old code snippets still work. |
comment:10
Making print a function is straightforward: It basically boils down to making Now for the preparser bit (that's the relatively hard part): It's very easy to detect if there's a I think this is actually not that bad to do: we're only rewriting code that would otherwise be a syntax error. Of course there are cases we don't catch, because there are print statements in python2 that are also valid syntax in python3, but with a different result: Python 2:
Python3:
I don't think there's anything we can do about that. Our only option is to interpret it as valid Py3. Note: It's tempting to reach into "2to3" and use its fixer for print. I don't think that will work very well, because 2to3 actually constructs a parse tree. Probably sage's preparser would be much nicer if it did that too, but it doesn't. So integrating 2to3's fixer would be painful. |
comment:11
Replying to @jdemeyer:
Replying to @fchapoton:
I agree with these two comments. The change to Python 3 will most likely break Python 2 written code as there are a lot more incompatible changes than Therefore a -1 for using the preparser for this. |
comment:13
I think this ticket is obsolete. |
Reviewer: Matthias Koeppe |
comment:14
I agree, let's close it |
Hello,
Given that we are trying to move into python3, should we preparse
into
with deprecation warning?
This will make sure that old code, written in python2 style could still run, and not fail because of a miserable print.
Cheers,
Edgar
CC: @kevindilks @jplab @kcrisman
Component: python3
Keywords: days88
Reviewer: Matthias Koeppe
Issue created by migration from https://trac.sagemath.org/ticket/23674
The text was updated successfully, but these errors were encountered: