Python SyntaxError message hard to understand
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SikuliX |
Fix Released
|
Critical
|
RaiMan |
Bug Description
This line of comments:
#In order to run this script the spreadsheet for MFW must be open already.
Caused this error:
[error] Stopped
[error] An error occurs at line 1
[error] Error message: SyntaxError: ("mismatched input 'd' expecting COLON", ('', 1, 112, "if len(sys.argv)==0 or 'C:/Documents and Settings/
It turns out it's because I had an apostrophe in the name of the sikuli folder. The script thought that the 'd at the end of the name was part of the programming.
Would it be possible to get sikuli to enforce proper naming or possibly have a clearer error message in the future?
Changed in sikuli: | |
status: | Won't Fix → Fix Committed |
importance: | Undecided → Critical |
tags: | added: idererun |
Changed in sikuli: | |
status: | Fix Committed → Fix Released |
This is not a bug, it is a feature ;-)
I admit, that especially the SyntaxError messages from Python/Jython are something you have to get used to:
In this case you used a ' inside a string, that is quoted with '
the solution: nidemers/ My Documents/Sikuli Projects/MFW Response Rec'd.sikuli/" != sys.argv[0]: sys.argv.insert(0, "C:/Documents and Settings/ nidemers/ My Documents/Sikuli Projects/MFW Response Rec'd.sikuli/")
if len(sys.argv)==0 or "C:/Documents and Settings/
use " if the string contains ' and vice versa.
this is a syntax error, because the inner ' ends the string and the directly following d (mismatched input 'd' expecting COLON) causes the error (I guess they talk about mismatched, because the d does not fit with any internally used regular expression)
So it has nothing to do with the comment.
--- Would it be possible to get sikuli to enforce proper naming or possibly have a clearer error message in the future?
Since we will not rewrite the Python syntax checker: nothing to do here.
The error message itself in Sikuli will be a bit more compact and structured in the future.