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 626785 - Assertion failure importing pygobject in Python 2.7 with warnings set to "error" (uses PyCObject API, deprecated in 2.7)
Assertion failure importing pygobject in Python 2.7 with warnings set to "err...
Status: RESOLVED WONTFIX
Product: pygobject
Classification: Bindings
Component: general
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: 2010-08-12 23:34 UTC by Dave Malcolm
Modified: 2010-10-12 16:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Dave Malcolm 2010-08-12 23:34:10 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
Comment 1 johnp 2010-10-12 16:47:29 UTC
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