title: How to list all exceptions a function could raise in Python 3?
body: <p>Is there a programmatic way to get a list of all exceptions a function could raise?</p>
  
  <p>I know for example that <a href="https://docs.python.org/3.4/library/os.html?highlight=os#os.makedirs" rel="noreferrer"><code>os.makedirs(path[, mode])</code></a> can raise <code>PermissionError</code> (and maybe others), but the documentation only mentions <a href="https://docs.python.org/3.4/library/exceptions.html#OSError" rel="noreferrer"><code>OSError</code></a>. (This is just an example - maybe even a bad one; I am not especially interested in this function - more in the problem in general).</p>
  
  <p>Is there a programmatic way to find all the possible exceptions when they are not/poorly documented? This may be especially useful in 3rd-party libraries and libraries that do not ship with Python source code.</p>
  
  <p>The solution presented in "<a href="https://stackoverflow.com/questions/1591319/python-how-can-i-know-which-exceptions-might-be-thrown-from-a-method-call">Python: How can I know which exceptions might be thrown from a method call</a>" does not work in Python 3; there is no <a href="https://docs.python.org/2/library/compiler.html" rel="noreferrer"><code>compiler</code></a> package.</p>