Python subclassing causes IDLE to restart
<p>I found this issue in a long, complex script, but while debugging stripped it down to this very minimal form which still causes the same problem:</p>

<pre><code>from PyQt5.QtWidgets import(QMainWindow)

class Window(QMainWindow):
    pass
</code></pre>

<p>When I import this class through the IDLE interpreter, then try to instantiate the class with </p>

<pre><code>w = Window()
</code></pre>

<p>the shell restarts with a "========== RESTART: Shell ===========" message.</p>

<p>These things fix the problem:</p>

<ul>
<li><p>Rewriting the code so that the Window class has no superclass:</p>

<pre><code>from PyQt5.QtWidgets import(QMainWindow)

class Window:
    pass
</code></pre></li>
<li><p>Running the code outside of IDLE by double-clicking the file when it has an "if <strong>name</strong>=='main':" conditional added</p></li>
</ul>

<p>These things do <em>not</em> fix the problem:</p>

<ul>
<li>Changing the name of the class</li>
<li>Changing the class used as a super</li>
</ul>

<p>The clincher is that when I go back and try to import/instantiate similarly subclassed classes from old scripts that worked fine in the past and haven't been touched in awhile, they now exhibit exactly the same problem.</p>

<p>So, as far as I can tell, I have an IDLE-specific problem that crashes/restarts the interpreter when it tries to instantiate any subclass, and which arose spontaneously where it wasn't present before.</p>

<p>Has anyone seen anything like this before?</p>

<p>Thanks for your help - as far as I can tell, there was in fact a clash between tkinter and Qt. A reinstall of my Python environment seems to have taken care of the problem!</p>

python class subclass python-idle