title: What are the python builtin __exit__ argument types?
body: <p>Classes have a defineable function <code>__exit__</code> that allows implementation of a context manager.</p>
  
  <p>It takes the required arguments:</p>
  
  <pre><code>def __exit__(self, exc_type, exc_val, exc_tb):
  </code></pre>
  
  <p>but I cannot find a definitive definition of what those arguments are and their types.</p>
  
  <p>Here's my best guess of what they are and why, but I'm not entirely sure:</p>
  
  <pre><code>def __exit__(self, exc_type: Exception, exc_val: TracebackException, exc_tb: TracebackType):
  </code></pre>
  
  <h2>exc_type</h2>
  
  <p>Python defines a <code>TracebackException</code> class that accepts an <code>exc_type</code> argument which is used contextually in the constructor within <a href="https://github.com/python/cpython/blob/master/Lib/traceback.py#L516" rel="noreferrer"><code>issubclass</code></a> with <code>SyntaxError</code>, which infers that <code>exc_type</code> is indeed some sort of <code>Exception</code>, which <code>SyntaxError</code> inherits from.</p>
  
  <h2>exc_val</h2>
  
  <p>Also, in that <code>TracebackException</code> class is an <code>exc_value</code> argument that matches up to our <code>exc_val</code> which seems to have various attributes like <code>__cause__</code>, <code>__context__</code>, and other attributes that are all defined in <code>TracebackType</code> itself. This makes me think that the parameter is itself an instance of <code>TracebackException</code>.</p>
  
  <h2>exc_tb</h2>
  
  <p>Python defines a <a href="https://github.com/python/cpython/blob/master/Lib/traceback.py#L305" rel="noreferrer">walk_tb</a> function that uses <code>exc_tb</code> as an argument (manually traced from <a href="https://docs.python.org/3/library/traceback.html" rel="noreferrer">docs.python.org</a>), and this object appears to have <code>tb_frame</code>, <code>tb_lineno</code>, and <code>tb_next</code> attributes which can be traced back to a <code>TracebackType</code> class in the <a href="https://github.com/python/typeshed/blob/master/stdlib/3/types.pyi#L235" rel="noreferrer"><code>typeshed</code></a> library.</p>
  
  <p>Thoughts?</p>