cascading python executions only if return code is 0

Ethan Furman ethan at
Mon Dec 23 13:38:23 CET 2013

On 12/22/2013 06:33 PM, Steven D'Aprano wrote:
> Roy Smith wrote:
>>          else:
>>              assert 0, "can't create picker (classes = %s)" % classes
> ¡Ay, caramba! I was with you until the very last line. The above code is
> possibly buggy and inappropriately designed. [...]
> First, the bug: there are circumstances where no exception is raised even if
> all the strategies fail.

Since Steven wasn't explicit about the circumstances, I'll list the two I'm aware of:  if Python is started with -O or 
-OO then assertions are cut from the code and do not run:

   ethan at media:~/source/python/issue19995$ ./python -O
   Python 3.4.0b1 (default:be22ffb4fdf1, Dec 20 2013, 12:26:10)
   [GCC 4.7.3] on linux
   Type "help", "copyright", "credits" or "license" for more information.
   --> assert 0, "Testing"
   --> # no exception raised

More information about the Python-list mailing list