[Python.NET] bug in exception handling

Jonathan Mizrahi mizrahi.jonathan at gmail.com
Sun Aug 16 03:53:01 CEST 2015


Hi,

I may have found a bug in how the clr package converts .net exceptions to
Python exceptions, at least as it relates to PyQt. If I try and add a
library which does not exist, and then try and print the exception, PyQt is
subsequently unable to initialize OLE. This means that PyQt applications
cannot use copy/paste and drag-and-drop.

Here is a minimal example:

import clr
import sys
from PyQt4 import QtGui

try:
    clr.AddReference('foo') #This doesn't exist
except Exception as e:
    print e
app = QtGui.QApplication(sys.argv)
app.exec_()

This results in the Qt error:

Qt: Could not initialize OLE (error 80010106)

The program runs, but copy/paste and drag-and-drop fails. If I do not try
and print the exception (replace the except block with 'pass'), the program
runs without any problems. Also, if the library exists I have no problems.

Is this something anyone has seen before?

Thanks!

Jonathan Mizrahi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20150815/5a9bc3db/attachment.html>


More information about the PythonDotNet mailing list