Chris's Wiki :: blog/python/NeverRaiseCoreExceptions Commentshttps://utcc.utoronto.ca/~cks/space/blog/python/NeverRaiseCoreExceptions?atomcommentsDWiki2016-09-08T17:41:36ZRecent comments in Chris's Wiki :: blog/python/NeverRaiseCoreExceptions.By Ram Rachum on /blog/python/NeverRaiseCoreExceptionstag:CSpace:blog/python/NeverRaiseCoreExceptions:75203086606cbac59a71318a63df26b8c71e351aRam Rachumhttps://ram.rachum.com/<div class="wikitext"><p>It's true that zipfile shouldn't raise RuntimeError in your case (I would make a WrongPasswordError class), but I don't think that your general conclusions, that third-party modules shouldn't raise built-in exceptions is true. Just as one example out of many, say that you're making a dict-like data structure, and someone is trying to access a key that doesn't exist. You should raise KeyError, no?</p>
<p>I can give many more examples.</p>
</div>2016-09-08T17:41:36ZBy Kevin Lyda on /blog/python/NeverRaiseCoreExceptionstag:CSpace:blog/python/NeverRaiseCoreExceptions:c2ec1c17df81a72f5a11ca9046a22580753ff60fKevin Lydahttps://phrye.com/<div class="wikitext"><p>@Nolan: What? That's insane. That's even worse - they let you set an error-handling function and then they call <code>exit(3)</code> anyway. Awesome.</p>
<p>The new gdbm apparently lets you set an error-handling function but does no call exit if it returns.</p>
<p>I went to see if <code>XSetIOErrorHandler</code> still does that and it does. But what I didn't know is that there's an alternative C library for X11 - XCB. Interesting.</p>
</div>2016-09-08T06:48:46ZBy Nolan on /blog/python/NeverRaiseCoreExceptionstag:CSpace:blog/python/NeverRaiseCoreExceptions:da9213f077859a29fae094e79b5902ba599cd405Nolanhttps://cumulusnetworks.com/<div class="wikitext"><p>@Kevin Xlib has a good example in XSetIOErrorHandler().</p>
<p>It sets a callback to handle the connection to the X server breaking. It also unconditionally calls exit if the callback returns.</p>
<p>I ran into this in the early days of VMware GSX, because server VMs would die if you had a console attached and the X server crashed/exited. I had optimized the "remote" console to use a local connection if the client and server were on the same machine.</p>
<p>I experimented with longjmp()ing out of the callback, but in the end I just made GSX always use the remote console protocol (a extension of VNC in those days) even when everything was local.</p>
</div>2016-09-08T00:37:12ZBy Kevin Lyda on /blog/python/NeverRaiseCoreExceptionstag:CSpace:blog/python/NeverRaiseCoreExceptions:2f900d9f37176cbae9278e1115a84bb55587065dKevin Lydahttps://phrye.com/<div class="wikitext"><p>Similar issue: <a href="http://puszcza.gnu.org.ua/projects/gdbm">gdbm</a> used to call <code>exit(3)</code> but as of the new version, 1.12.90 (released sometime in July of this year apparently) it no longer does this. It was always my example C library that Did A Bad Thing by inflicting <code>exit(3)</code> on unsuspecting users.</p>
</div>2016-09-07T08:28:49Z