Bug 342730

Summary: Make it able to run python code with comments
Product: [Applications] cantor Reporter: Minh Ngo <nlminhtl>
Component: python2-backendAssignee: Filipe Saraiva <filipe>
Status: RESOLVED FIXED    
Severity: normal CC: alexanderrieder
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Minh Ngo 2015-01-11 13:02:40 UTC
Currently this code can be run:
print(1 + 2) #some comment,

but this one will return an error:

#some comment
print(1 + 2)

Comments are important part for the code, and it will be nice to make it runnable too with code.

Reproducible: Always

Steps to Reproduce:
1. print:
#some comment
print(1 + 2)
2. and try to run this code

Actual Results:  
Error

Expected Results:  
3

I will work on this problem :)
Comment 1 Filipe Saraiva 2015-01-12 08:38:13 UTC
Hum, you can to run it in previous stable Cantor version. I will review your patch.
Comment 2 Minh Ngo 2015-01-12 08:40:42 UTC
Not sure, doesn't work with the stable release of Cantor in Fedora 20 at least.

Anyway, I have added unit tests to be sure that it didn't work.
Comment 3 Minh Ngo 2015-01-13 19:50:13 UTC
Git commit c81c2f71fe134f652fef3aca83733d79556f875c by Minh Ngo.
Committed on 13/01/2015 at 19:44.
Pushed by minhngo into branch 'frameworks'.

Makes it able to run python code with comments & a bit of refactoring.
REVIEW: 122005

M  +33   -21   src/backends/python/pythonsession.cpp
M  +21   -4    src/backends/python2/testpython2.cpp
M  +3    -3    src/backends/python2/testpython2.h

http://commits.kde.org/cantor/c81c2f71fe134f652fef3aca83733d79556f875c