Legitimate to raise SyntaxError for non-Python syntax errors?

Oleg Broytmann phd at phd.fep.ru
Sat Jun 23 10:09:26 EDT 2001


Hello!

   I made a patch for Zope (was incorporated into Zope 2.4.0a1), and the
code raise SynaxError on - yes, syntax errors in the input streams my code
parses. It is in the dtml-in sort attribute; my code requires sort order to
be either ASC or DESC (case-insensitive). If not it raises SyntaxError.

On Sat, 23 Jun 2001, Tim Peters wrote:
> [Hamish Lawson]
> > Is it legitimate to use the SyntaxError exception for non-Python
> > syntax errors, say by a parser when it encounters violations in the
> > syntax of the data format or mini-language it is parsing? I'd always
> > assumed that SyntaxError was meant for just Python syntax errors, ...
>
> I doubt anyone will object.  Thousands of programs reuse Python's ValueError and
> TypeError, and while SyntaxError reuse is less common, it seems like it's much
> the same thing.  Just because Guido took all the good exception names first
> doesn't mean he gets to keep them to himself <wink>.

Oleg.
----
     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.





More information about the Python-list mailing list