Ctypes Fang Ausnahme

Ich spiele ein bisschen mit ctypes und C / C ++ - DLLs. Ich habe eine recht einfache "math" -Dll

<code>double Divide(double a, double b)
{
    if (b == 0)
    {
       throw new invalid_argument("b cannot be zero!");
    }

    return a / b;
}
</code>

Es funktioniert soweit das einzige Problem, ich bekomme eine WindowsError-Ausnahme in Python und ich kann den Text nicht abrufenb kann nicht null sein Gibt es einen speziellen Ausnahmetyp, den ich werfen muss? Oder muss der Python-Code geändert werden? Python-Code:

<code>from ctypes import *

mathdll=cdll.MathFuncsDll
divide = mathdll.Divide
divide.restype = c_double
divide.argtypes = [c_double, c_double]

try:
    print divide (10,0)
except WindowsError:
    print "lalal"
except:
    print "dada"
</code>

Antworten auf die Frage(2)

Ihre Antwort auf die Frage