GNOME Bugzilla – Bug 449879
An error in pyg_gerror_exception_check
Last modified: 2007-07-02 17:55:10 UTC
I'm using the function pyg_gerror_exception_check and get a segmentation fault in python in PyType_IsSubtype. It seems that the problem is in gobjectmodule.c: pyg_gerror_exception_check in the call of the function "PyErr_GivenExceptionMatches(type, (PyObject *) &gerror_exc)" I think the second parameter "(PyObject *) &gerror_exc" should be just "gerror_exc".
Created attachment 90972 [details] [review] Fix a bug pyg_gerror_exception_check This small patch (one character deleted) should fix the reported bug.
(In reply to comment #1) > Created an attachment (id=90972) [edit] > Fix a bug pyg_gerror_exception_check > > This small patch (one character deleted) should fix the reported bug. > Seems obviously correct. Do you have a testcase? It would be good to have it incorporated in out testsuite.
(In reply to comment #2) > Seems obviously correct. Do you have a testcase? It would be good to have it > incorporated in out testsuite. No, I haven't a testcase. I get this error in the C wrapper of an interface function implemented in python. I have take a look at the test cases in tests directory. Perhaps I can add a GError **argument to the iface_method of testhelper.Interface and return an exception in one case.
Created attachment 90980 [details] [review] A test case for this bug Here is a test case checking pyg_gerror_exception_check and in addition, the reverse function (GError->exception) pyg_error_check. I have added a GError ** argument to the iface_method function of testhelper.Interface and raise an exception in one case.
Comment on attachment 90980 [details] [review] A test case for this bug Great to have a test, but wouldn't it be better to just have a special function in the testmodule which raises a GError?
(In reply to comment #5) > Great to have a test, but wouldn't it be better to just have a special function > in the testmodule which raises a GError? Do you mean add a new interface function to testhelper.Interface or add another function that just raise a GError ? I'm rather a beginner in python so I'm trying to stay quite close to something already existing. I have thought about the first solution but reusing an existing function was just easier for me, I can add a new function is you prefer. Then, for the second solution, the error happens in the C code and I don't know how to check it directly, so I think I need another conversion from C to python and this is done easily with an interface.
(In reply to comment #6) > (In reply to comment #5) > > Great to have a test, but wouldn't it be better to just have a special function > > in the testmodule which raises a GError? > > Do you mean add a new interface function to testhelper.Interface or add another > function that just raise a GError ? > > I'm rather a beginner in python so I'm trying to stay quite close to something > already existing. > > I have thought about the first solution but reusing an existing function was > just easier for me, I can add a new function is you prefer. > Then, for the second solution, the error happens in the C code and I don't know > how to check it directly, so I think I need another conversion from C to python > and this is done easily with an interface. > Just go into testhelpermodule.c and copy a _wrap_XXX method, modify and add an entry in testhelper_functions, since you're not testing any interfaces, you're testing GErrors.
Created attachment 91043 [details] [review] Another test case for this bug Here is a test case not using an interface. The python checking function testGError in test/test_gtype.py, call the helper C function testhelper.test_gerror_exception which call itself the python function generating the exception raiseGError. The exception returned is converted by the C function into a GError and then back into an python exception.
Perfect, thanks for the patch I committed it; Sending ChangeLog Sending gobject/gobjectmodule.c Sending tests/test_gtype.py Sending tests/testhelpermodule.c Transmitting file data .... Committed revision 678.