[Python-Dev] SyntaxError for illegal literals

Guido van Rossum guido@digicool.com
Thu, 15 Feb 2001 09:51:53 -0500


> [Ka-Ping Yee]
> > ...
> > The only exceptions that don't currently conform, as far as i
> > know, have to do with invalid literals.

[Tim]
> Pretty much, but nothing's *that* easy.
> 
> Other examples:
> 
> + If there are too many nested blocks, it raises SystemError(!).
> 
> + MemoryError is raised if a dotted name is too long.
> 
> + OverflowError is raised if a string is too long.
> 
> Note that those don't have to do with syntax, they're arbitrary
> implementation limits.  So that's the rule:  raise
> 
>     SystemError if something is bigger than 20
>     MemoryError if it's bigger than 1000
>     OverflowError if it's bigger than an int
> 
> Couldn't be clearer <wink>.
> 
> + SystemErrors are raised in many other places in the role of internal
> assertions failing.  Those needn't be changed.

Note that MemoryErrors are also raised whenever new objects are
created, which happens all the time during the course of compilation
(both Jeremy's symbol table code and of course code objects).  These
needn't be changed either.

--Guido van Rossum (home page: http://www.python.org/~guido/)