Bug 411645 - Make sagemath backend compatible with sagemath built with python3
Summary: Make sagemath backend compatible with sagemath built with python3
Status: RESOLVED FIXED
Alias: None
Product: cantor
Classification: Applications
Component: sage-backend (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Nikita Sirgienko
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-06 16:44 UTC by pcpa
Modified: 2019-12-05 23:38 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 19.12.0
Sentry Crash Report:


Attachments
cantor-sagemath-python3.patch (1.13 KB, patch)
2019-09-06 16:44 UTC, pcpa
Details

Note You need to log in before you can comment on or make changes to this bug.
Description pcpa 2019-09-06 16:44:13 UTC
Created attachment 122512 [details]
cantor-sagemath-python3.patch

I am working on some updates to the Fedora sagemath package.
  This attached patch works with both, python2 and python3.
  The reason of the patch is self described below:

$ python3 -c 'print 1, 2'
  File "<string>", line 1
    print 1, 2
          ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(1, 2)?
$ python3 -c 'print(1, 2)'
1 2
Comment 1 Nikita Sirgienko 2019-09-08 19:07:08 UTC
Hi

First, if you are familiar with development, then there is phabricator.kde.org for suggestions like this.
Second, there is tests for Cantor sage backend, and on my machine (SageMath 8.7 based on python2) one of them is failed (TestSage::testPlot(), testsage.cpp::92).

So, on this moment, I can't accept the patch, because it breaks appearing of plots appearing for SageMath, based on python2.

But, anyway, this problem is important, so, if this patch won't be improved for working with Python2, I think, I just will add a option "SageMath python 3 compatibility".
Comment 2 pcpa 2019-09-09 17:50:22 UTC
(In reply to Nikita Sirgienko from comment #1)
> Hi
> 
> First, if you are familiar with development, then there is
> phabricator.kde.org for suggestions like this.
> Second, there is tests for Cantor sage backend, and on my machine (SageMath
> 8.7 based on python2) one of them is failed (TestSage::testPlot(),
> testsage.cpp::92).
> 
> So, on this moment, I can't accept the patch, because it breaks appearing of
> plots appearing for SageMath, based on python2.
> 
> But, anyway, this problem is important, so, if this patch won't be improved
> for working with Python2, I think, I just will add a option "SageMath python
> 3 compatibility".

  Many thanks for checking it. I am not much familiar with phabricator.kde.org
  For some reason, while working on parallel with several issues related
to the sagemath rpm package, when submitting the report I though the patch
could be simplified, but it cannot.
  The proper line for two arguments would be:

print("%s %s" % ('____TMP_DIR____', sage.misc.misc.SAGE_TMP))

  python2 would generate different output. For example:

$ python2 -c 'print("foo", "bar")'
('foo', 'bar')
$ python3 -c 'print("foo", "bar")'
foo bar
$ python2 -c 'print("%s %s" % ("foo", "bar"))'
foo bar

  I was actually testing a patch with the later version, but got confused and
for some reason thought it could be simplified.
Comment 3 Nikita Sirgienko 2019-11-28 12:02:20 UTC
Egh, sory for delay, my email have lost a mail about your comment.

So, with line

print("%s %s" % ('____TMP_DIR____', sage.misc.misc.SAGE_TMP))

all tests works fine, so you want this changes to Cantor source code, right?
Comment 4 pcpa 2019-12-05 12:34:29 UTC
  Hi,

  Yes, it would be a good change to cantor.
This change will make cantor work if sagemath is built with python3
or python2. Currently upstream is building with python2, but is finishing
porting to python3. I believe currently only the latest Fedora sagemath
packages are built with python3.
Comment 5 Nikita Sirgienko 2019-12-05 23:09:11 UTC
Git commit 802fb9f44fa95614a8bb0872ea1b4cc485913d82 by Nikita Sirgienko.
Committed on 05/12/2019 at 22:56.
Pushed by sirgienko into branch 'release/19.12'.

Add compatibility with Sage based on Python3
FIXED-IN: 19.12.1

M  +2    -2    src/backends/sage/sagesession.cpp

https://invent.kde.org/kde/cantor/commit/802fb9f44fa95614a8bb0872ea1b4cc485913d82