Bug 409240

Summary: warning messages stop execution
Product: [Applications] cantor Reporter: avlas <jsardid>
Component: python3-backendAssignee: Nikita Sirgienko <warquark>
Status: RESOLVED FIXED    
Severity: normal CC: warquark
Priority: NOR    
Version: 19.04   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 19.08
Sentry Crash Report:

Description avlas 2019-06-27 10:31:47 UTC
Would you consider displaying warnings without breaking execution? This is how it works upstream in contrast to errors. I recall this option was implemented in Octave recently. Could you please port it to Python? 

Maybe other backends are affected as well.
Comment 1 Nikita Sirgienko 2019-06-27 11:57:52 UTC
Myabe i could catch warning and not threat them as error
Comment 2 avlas 2019-06-27 12:04:54 UTC
(In reply to Nikita Sirgienko from comment #1)
> Myabe i could catch warning and not threat them as error

That would be great
Comment 3 avlas 2019-07-05 17:35:07 UTC
I was wondering if there is any progress on this issue.

Asking because there is a use case that I have identified that deviates from regular python, IPython, etc.

It's about a code that removes columns from a panda dataframe:

- In regular python, a warning is displayed (only the first time) and columns are removed. Invoking the same instruction again triggers an error because these columns are present no more.

- In Cantor, the warning is treated as an error, so the columns are not removed, and the user needs to run the instruction twice to get it done. After that, invoking the instruction again fails as one would expect.

In this context, I think a Python user that is not aware of the issue will not understand what is really going on under the hood.

More generally, I would encourage to treat all warning as messages to be displayed in Cantor. 

I think this would also be more consistent with Jupyter Notebooks (btw, I look forward to trying the import/export functionality between notebooks and cantor from the GSoC!).
Comment 4 Nikita Sirgienko 2019-07-05 17:51:08 UTC
I can't say, that I use python often, but according your words the problem more important, that I have thought befor, so I give it more priority.
Comment 5 avlas 2019-07-05 17:52:55 UTC
(In reply to Nikita Sirgienko from comment #4)
> I can't say, that I use python often, but according your words the problem
> more important, that I have thought befor, so I give it more priority.

Thank you very much!
Comment 6 Nikita Sirgienko 2019-07-05 22:05:07 UTC
Git commit 4bc20243ad683c0f828e1a605adf75d4ddf331d5 by Nikita Sirgienko.
Committed on 05/07/2019 at 22:03.
Pushed by sirgienko into branch 'master'.

[Python] Show Python warnings not as errors, but as text results
FIXED-IN: 19.08

M  +6    -0    src/backends/python/pythonexpression.cpp
M  +1    -0    src/backends/python/pythonexpression.h
M  +12   -1    src/backends/python/pythonserver.cpp
M  +3    -1    src/backends/python/pythonserver.h
M  +2    -0    src/backends/python/pythonservermain.cpp
M  +12   -3    src/backends/python/pythonsession.cpp
M  +9    -0    src/backends/python2/testpython2.cpp
M  +2    -0    src/backends/python2/testpython2.h
M  +9    -0    src/backends/python3/testpython3.cpp
M  +2    -0    src/backends/python3/testpython3.h

https://commits.kde.org/cantor/4bc20243ad683c0f828e1a605adf75d4ddf331d5
Comment 7 avlas 2019-07-05 23:24:29 UTC
(In reply to Nikita Sirgienko from comment #6)
> Git commit 4bc20243ad683c0f828e1a605adf75d4ddf331d5 by Nikita Sirgienko.
> Committed on 05/07/2019 at 22:03.
> Pushed by sirgienko into branch 'master'.
> 
> [Python] Show Python warnings not as errors, but as text results
> FIXED-IN: 19.08
> 
> M  +6    -0    src/backends/python/pythonexpression.cpp
> M  +1    -0    src/backends/python/pythonexpression.h
> M  +12   -1    src/backends/python/pythonserver.cpp
> M  +3    -1    src/backends/python/pythonserver.h
> M  +2    -0    src/backends/python/pythonservermain.cpp
> M  +12   -3    src/backends/python/pythonsession.cpp
> M  +9    -0    src/backends/python2/testpython2.cpp
> M  +2    -0    src/backends/python2/testpython2.h
> M  +9    -0    src/backends/python3/testpython3.cpp
> M  +2    -0    src/backends/python3/testpython3.h
> 
> https://commits.kde.org/cantor/4bc20243ad683c0f828e1a605adf75d4ddf331d5

Perfect!