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 374653 - missing else breaks None->NULL for boxed types
missing else breaks None->NULL for boxed types
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: 363694
 
 
Reported: 2006-11-13 12:11 UTC by James "Doc" Livingston
Modified: 2007-04-30 05:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (491 bytes, patch)
2006-11-13 12:13 UTC, James "Doc" Livingston
committed Details | Review

Description James "Doc" Livingston 2006-11-13 12:11:10 UTC
pygtypes.c is missing an "else", which means that pyg_value_from_pyobject() can't convert None into NULL for boxed types, and instead throws a TypeError.
Comment 1 James "Doc" Livingston 2006-11-13 12:13:14 UTC
Created attachment 76474 [details] [review]
patch

This trivial patch fixes it for me.
Comment 2 Johan (not receiving bugmail) Dahlin 2006-11-13 12:41:36 UTC
James: Thanks for the patch, do you think you can write a simple test case to demonstrate the bug too?
Comment 3 Ed Catmur 2007-02-20 03:29:45 UTC
Here's a standalone unittest:

import unittest

import gobject, sys

class C (gobject.GObject):
	__gsignals__ = { 'my-boxed-signal': (gobject.SIGNAL_RUN_LAST, 
		gobject.type_from_name('GStrv'), ()) }

class TestPyGValue(unittest.TestCase):
	def testNoneNULLBoxedConversion(self):
		obj = C ()
		obj.connect ('my-boxed-signal', lambda obj: None)
		sys.last_type = None
		obj.emit ('my-boxed-signal')
		assert not sys.last_type

if __name__ == '__main__':
	unittest.main()

Sorry about the futzing with sys.last_type - not sure how best to get at an exception in a PyGClosure.
Comment 4 Johan (not receiving bugmail) Dahlin 2007-04-30 02:48:41 UTC
James, Ed: Thanks for the patch/test.

This got committed to svn trunk as revision 657.
Comment 5 Alex Lancaster 2007-04-30 05:13:48 UTC
Update patch status.