After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 449879 - An error in pyg_gerror_exception_check
An error in pyg_gerror_exception_check
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: gobject
Git master
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2007-06-21 21:13 UTC by Sébastien Granjoux
Modified: 2007-07-02 17:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix a bug pyg_gerror_exception_check (520 bytes, patch)
2007-07-01 15:13 UTC, Sébastien Granjoux
none Details | Review
A test case for this bug (4.27 KB, patch)
2007-07-01 18:05 UTC, Sébastien Granjoux
none Details | Review
Another test case for this bug (2.30 KB, patch)
2007-07-02 17:49 UTC, Sébastien Granjoux
none Details | Review

Description Sébastien Granjoux 2007-06-21 21:13:55 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".
Comment 1 Sébastien Granjoux 2007-07-01 15:13:52 UTC
Created attachment 90972 [details] [review]
Fix a bug pyg_gerror_exception_check

This small patch (one character deleted) should fix the reported bug.
Comment 2 Johan (not receiving bugmail) Dahlin 2007-07-01 15:30:58 UTC
(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.
Comment 3 Sébastien Granjoux 2007-07-01 16:42:50 UTC
(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.
Comment 4 Sébastien Granjoux 2007-07-01 18:05:01 UTC
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 5 Johan (not receiving bugmail) Dahlin 2007-07-01 18:06:55 UTC
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?
Comment 6 Sébastien Granjoux 2007-07-01 19:42:17 UTC
(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.
Comment 7 Johan (not receiving bugmail) Dahlin 2007-07-01 20:00:42 UTC
(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.
Comment 8 Sébastien Granjoux 2007-07-02 17:49:41 UTC
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.
Comment 9 Johan (not receiving bugmail) Dahlin 2007-07-02 17:55:10 UTC
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.