title: Why decorator-style context manager in Python doesn't catch exception within Tkinter window?
body: <p>there is a simple code with decorator-generated context manager via contextlib. When I press button exception raised and DOES NOT handled by context manager. Why is it?</p>
  
  <pre><code>from Tkinter import Tk, Button
  from contextlib import contextmanager
  
  
  def close_window(): 
      window.destroy()
      raise Exception
  
  
  @contextmanager
  def safe():
      try:
          yield
      except:
          print 'Exception catched'
  
  with safe():
      window = Tk()
      button = Button(window, text='Press me', command=close_window)
      button.pack()
      window.mainloop()
  </code></pre>
  
  <p>Why does exception still raise?</p>
  
  <p>UPD I use Python 2.7</p>