Python3-compatible syntax

130 views
Skip to first unread message

Jori Mäntysalo

unread,
Dec 11, 2016, 3:14:01 AM12/11/16
to sage-...@googlegroups.com
Latest beta is now almost Python3-compatible at syntax level, that is

find src/sage -name '*.py' | xargs -n 1 python3 -m py_compile

outputs almost nothing. However, there is now a lambda-line in
src/sage/graphs/generators/smallgraphs.py that needs Python2.

Please check you syntax against Py3 when making patches. That will save
time later.

--
Jori Mäntysalo

Samuel Lelievre

unread,
Dec 11, 2016, 5:02:50 AM12/11/16
to sage-devel

Frédéric Chapoton

unread,
Dec 11, 2016, 9:01:08 AM12/11/16
to sage-devel
Hello,

Regression in the move to python3 is happening all the time, and it is indeed very annoying.

Making a test target and a buildbot may be easier once at least all our cython files are correctly cythonized in py3. This is blocked by the removal of cmp() in all .pyx files. Not an easy task, as the remaining instances involve coercion, parents and elements. Experts would be welcome to help.

I would also like that the doctests are run using the python3 syntax for print. Does anybody know how to do that ? A priori, all tests should pass.

If this is possible, the next thing to do will be to run doctests with the range turned into an iterator. In this case, some tests still need care to pass.

Frederic

Travis Scrimshaw

unread,
Dec 11, 2016, 10:46:00 AM12/11/16
to sage-devel

Regression in the move to python3 is happening all the time, and it is indeed very annoying.

Making a test target and a buildbot may be easier once at least all our cython files are correctly cythonized in py3. This is blocked by the removal of cmp() in all .pyx files. Not an easy task, as the remaining instances involve coercion, parents and elements. Experts would be welcome to help.

I can assist sporadically, but unfortunately I can't commit any serious time to working on it. Thank you for all your work on getting us to Python3.

I would also like that the doctests are run using the python3 syntax for print. Does anybody know how to do that ? A priori, all tests should pass.

We probably just need to do the correct future imports in the doctesting framework. I remember you saying at a few points some future imports had this as a side effect.

If this is possible, the next thing to do will be to run doctests with the range turned into an iterator. In this case, some tests still need care to pass.


Best,
Travis
 

Sébastien Labbé

unread,
Dec 12, 2016, 4:41:13 AM12/12/16
to sage-devel

Please check you syntax against Py3 when making patches. That will save
time later.

I added a section "Authors/Reviewer's check list" to the page:
https://wiki.sagemath.org/Python3-compatible%20code

Is there any thing else an author/reviewer should check?

I also discoverd that other page on the wiki:
https://wiki.sagemath.org/PortingToPython3

I added a link to both page from the home page:
https://wiki.sagemath.org

Jori Mäntysalo

unread,
Dec 12, 2016, 4:53:14 AM12/12/16
to sage-devel
On Mon, 12 Dec 2016, Sébastien Labbé wrote:

> I added a section "Authors/Reviewer's check list" to the page:
> https://wiki.sagemath.org/Python3-compatible%20code

Thanks.

I think using find for all .py -files is enought. If someone wants to save
few seconds, it is also possible to run

git diff --name-only develop your-new-branch | xargs python3...

--
Jori Mäntysalo

David Roe

unread,
Dec 12, 2016, 5:10:46 AM12/12/16
to sage-devel
There's a python3 compatibility trac plugin; presumably reviewers should just pay attention to that?  For example, see the list on the right at https://patchbot.sagemath.org/ticket/21996/
David

Frédéric Chapoton

unread,
Dec 12, 2016, 3:30:02 PM12/12/16
to sage-devel, roed...@gmail.com
The patchbot plugin is not enough. I did my best to shape it to prevent regression, but it is far from perfect in detecting possible problems.

Of course, people should care about the results of this plugin. But we need also buildbots to check that no regression happens in the build process.

Frederic
Reply all
Reply to author
Forward
0 new messages