GNOME Bugzilla – Bug 626785
Assertion failure importing pygobject in Python 2.7 with warnings set to "error" (uses PyCObject API, deprecated in 2.7)
Last modified: 2010-10-12 16:47:29 UTC
Similarly to bug 623965 (pygtk), pygobject uses the PyCObject API to pass around API hooks: http://git.gnome.org/browse/pygobject/tree/gobject/pygobject.h This API is deprecated in Python 2.7; see: http://docs.python.org/dev/whatsnew/2.7.html#capsules This leads to gobject._gobject failing to be imported if the default warning settings (ignore deprecation warnings) are overridden: Overriding to an error leads to a hard failure of the python process: Python 2.7 (r27:82500, Jul 28 2010, 18:07:57) [GCC 4.5.0 20100716 (Red Hat 4.5.0-3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import warnings >>> print warnings.filters [('ignore', None, <type 'exceptions.DeprecationWarning'>, None, 0), ('ignore', None, <type 'exceptions.PendingDeprecationWarning'>, None, 0), ('ignore', None, <type 'exceptions.ImportWarning'>, None, 0), ('ignore', None, <type 'exceptions.BytesWarning'>, None, 0)] >>> warnings.filterwarnings('error') >>> import gobject python: /root/rpmbuild/BUILD/Python-2.7/Objects/dictobject.c:759: PyDict_SetItem: Assertion `value' failed. Aborted Clearing the filters leads to just a warning: Python 2.7 (r27:82500, Jul 28 2010, 18:07:57) [GCC 4.5.0 20100716 (Red Hat 4.5.0-3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import warnings >>> warnings.filters=[] >>> import gobject /usr/lib64/python2.7/site-packages/gtk-2.0/glib/__init__.py:22: PendingDeprecationWarning: The CObject type is marked Pending Deprecation in Python 2.7. Please use capsule objects instead. from glib._glib import * /usr/lib64/python2.7/site-packages/gtk-2.0/gobject/constants.py:24: PendingDeprecationWarning: The CObject type is marked Pending Deprecation in Python 2.7. Please use capsule objects instead. import gobject._gobject
The fix for this is in bug #630844 but it requires a full recompile of all modules because it breaks ABI. As upstream is considering undepricating this for future 2.7 releases I feel it is better to keep ABI for 2.7 and break it in 3.x