Python SyntaxError message hard to understand

Bug #1079319 reported by Nicole Demers
6
This bug affects 1 person
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/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/')\n"))

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?

Tags: idererun
Revision history for this message
RaiMan (raimund-hocke) wrote :

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:
if len(sys.argv)==0 or "C:/Documents and Settings/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/")

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.

Changed in sikuli:
status: New → Won't Fix
assignee: nobody → RaiMan (raimund-hocke)
milestone: none → x1.0
summary: - Comment line throws a syntax error
+ Python SyntaxError message hard to understand
RaiMan (raimund-hocke)
Changed in sikuli:
status: Won't Fix → Fix Committed
importance: Undecided → Critical
tags: added: idererun
RaiMan (raimund-hocke)
Changed in sikuli:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.