[Python-Dev] more SyntaxError subclasses!
Fredrik Lundh" <firstname.lastname@example.org
Wed, 12 Jul 2000 17:43:45 +0200
here are a bunch of other syntax error subclasses that
might be useful:
"you cannot use this statement here"
"you cannot assign to this target"
"sorry, this is a compiler restriction, not really a language =
"exceeded compiler limit"
"you cannot use this token here"
"there's something wrong with this function/method declaration"
"the argument declaration isn't correct"
here's how they're used in the current interpreter (before
the TabError/IndentationError patches):
ArgumentError: "duplicate keyword argument"
ArgumentError: "keyword can't be an expression"
ArgumentError: "non-default argument follows default argument"
ArgumentError: "non-keyword arg after keyword arg"
AssignmentError: "can't assign to ()"
AssignmentError: "can't assign to "
AssignmentError: "can't assign to function call"
AssignmentError: "can't assign to lambda"
AssignmentError: "can't assign to literal"
AssignmentError: "can't assign to operator"
LimitError: "expression too long"
LimitError: "more than 255 arguments"
StatementError: "'break' outside loop"
StatementError: "'continue' not properly in loop"
StatementError: "'return' outside function"
StatementError: "default 'except:' must be last"
StatementError: "name is local and global"
SyntaxError: "invalid syntax"
SyntaxError: "unexpected EOF while parsing"
SyntaxError: "unknown parsing error"
TabError: "inconsistent use of tabs and spaces in indentation"
TokenError: "invalid token"
(I'm extra interested in arguments from people who think TabError
and IndentationError is a good idea, but that this one sucks. I'm
not sure I want to hear from people who thinks that this one is a
great idea ;-)
on a more serious note, I think it would be great to add a distinct
attribute to the SyntaxError instance (an error number, most likely).
this could be used by an IDE to provide concise info without having
to parse the error message.
I'll post a more complete proposal later...