eval() of empty string hangs

Peter Hansen peter at engcorp.com
Wed Jul 28 16:21:44 CEST 2004

Chris Connett wrote:

> When I eval the empty string in this context, instead of a
> SyntaxError, like I expect and am prepared to handle, the program
> hangs.  If I run the example in a standard interactive shell, it
> raises a SyntaxError, like I expect.  Only here does it hang.
> I should be able to work around this, just check a special case for
> the empty string, since that seems to be the only actual case that
> arises, but this problem is a real puzzle to me, and I wanted to throw
> it out there to see what others think.

As an alternative, and not requiring that you special case
anything, does it work if you simply append '\n' to the
string to be eval'ed in all cases?


More information about the Python-list mailing list