[New-bugs-announce] [issue25832] Document weird behavior of `finally` when it has `break` in it

Ram Rachum report at bugs.python.org
Thu Dec 10 09:08:20 EST 2015


New submission from Ram Rachum:

Today I spent 30 minutes because of weird behavior of `finally` when it has a `break` statement inside of it. (The behavior is that the exception gets suppressed, which I found unexpected.) I think this behavior should be documented.

Example:

    
    
    c:\Users\Administrator\Desktop>cat s.py                    
    for x in [1, 2, 3]:                                        
      try:                                                     
        1/0                                                    
      finally:                                                 
        break                                                  
    print(x)                                                   
                                                              
    c:\Users\Administrator\Desktop>c:\Python34\python.exe s.py 
    1

----------
assignee: docs at python
components: Documentation
messages: 256173
nosy: cool-RR, docs at python
priority: normal
severity: normal
status: open
title: Document weird behavior of `finally` when it has `break` in it
type: enhancement

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25832>
_______________________________________


More information about the New-bugs-announce mailing list