Hi,

In a CPython lib I have an _init() method wich take one argument, a file name.

    char *fname;

    if (!PyArg_ParseTuple(args, "s", &fname))
        return NULL;

So, if I instanciate my object with a bad argument I've a good error message:

tif = ImgProc(123)
TypeError: argument 1 must be str, not int
(followed by the traceback)

But if I do:
try:
    tif = ImgProc(123)
except Exception as why:
    print("Error:", why)

I get just:

Error: <class '_liboqapy.ImgProc'> returned a result with an error set

Without traceback. That's not very usefull.

I prefer to keep the instanciation of this object into a try-except bloc but how to read the error message ?


Vincent

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to