[Python-bugs-list] Blank except block fails in try statement (PR#60)

Skip Montanaro skip@mojam.com (Skip Montanaro)
Sun, 22 Aug 1999 07:25:25 -0500 (CDT)


    Dan> When you have an empty except: block in a try statement, both
    Dan> MacPython 1.5.2b1 and Linux Python 1.5.2 report that you have
    Dan> invalid syntax.

That's neither a bug nor a feature.  It's a syntax error.  Blocks can't be
empty, hence the pass statement's raison d'etre:

    try:
	print "this is a test"
	raise(error)
    except:
	pass
    else:
	print "pleasent dreams"

    Dan> The easiest way to fix this is by adding a single line to the empty
    Dan> exception block:

And Bob's your uncle! ;-)

Skip Montanaro | http://www.mojam.com/
skip@mojam.com | http://www.musi-cal.com/~skip/
847-971-7098   | Python: Programming the way Guido indented...