title: How to stop Python from printing out ignored Exceptions from other libraries?
body: <p>I'm having a bit of a problem with how Python3 is handling a specific Exception, which should be ignored, but that gets printed out anyway at the end of execution along with a Traceback.</p>
  
  <p>Specifically, I use the <a href="https://graph-tool.skewed.de/" rel="nofollow noreferrer">graph-tool</a> library to launch an interactive window, like so:</p>
  
  <pre><code>graph_tool.draw.interactive_window(self.graphtool_graph, vertex_text=self.v_label, vertex_font_size=6,geometry=(1920, 1080))
  </code></pre>
  
  <p>And my problem arises if I close the window that is opened <em>before</em> it finishes drawing and laying out the graph itself. Then, when execution of my code is finished, I get this printout:</p>
  
  <pre><code>Exception ignored in: &lt;bound method GraphWindow.__del__ of &lt;gtk_draw.GraphWindow object at 0x7f221ccf3750 (graph_tool+draw+gtk_draw+GraphWindow at 0x4c662a0)&gt;&gt;
  Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/graph_tool/draw/gtk_draw.py", line 1183, in __del__
    File "/usr/lib/python3/dist-packages/graph_tool/draw/gtk_draw.py", line 375, in cleanup
    File "/usr/lib/python3/dist-packages/gi/overrides/__init__.py", line 68, in __get__
  TypeError: 'NoneType' object is not callable
  </code></pre>
  
  <p>Which is obviously not very nice to see, especially if it's an end user interacting with my project.</p>
  
  <p>I tried to enclose the call to <code>draw.interactive_window</code> in a try-catch statement, like so:</p>
  
  <pre><code>        try:
              graph_tool.draw.interactive_window(self.graphtool_graph, vertex_text=self.v_label, vertex_font_size=6,
                                                 geometry=(1920, 1080))
          except TypeError:
              # Interactive Window closed before it finished drawing the graph. It would throw an exception that is
              # quite ugly to see. Let's ignore it.
              return
  </code></pre>
  
  <p>But I end up with the same problem. I even tried not specifying the <code>TypeError</code> exception and use a blanket <code>except</code>, but to no avail. </p>
  
  <p>Does anyone know of a way to stop Python from printing out this exception?</p>
  
  <p>P.S.: I found this <a href="https://bugs.python.org/issue35743" rel="nofollow noreferrer">issue</a> on the Python bug tracker, which seems to be related. In the attached discussion this is framed as a feature™ and not a bug, but I would still like to understand if it is possible in any way to stop this Exception from printing, especially when I am explicitly trying to catch it and ignore it.</p>