Re: [Python-Dev] Exception message for invalid with statement usage

2006-09-06 Thread Guido van Rossum
IMO it's fine. The only time you'll see this in reality is when someone passed you the wrong type of object by mistake, and then the type mentioned in the message is plenty help to debug it. Anyone with even a slight understanding of 'with' knows it involves '__exit__', and the linenumber should be

Re: [Python-Dev] Exception message for invalid with statement usage

2006-09-06 Thread Nick Coghlan
Georg Brandl wrote: > Current trunk: > with 1: > ... print "1" > ... > Traceback (most recent call last): > File "", line 1, in > AttributeError: 'int' object has no attribute '__exit__' > > Isn't that a bit crude? For "for i in 1" there's a better > error message, so why shouldn't the a