Ubuntu 12.04 bug: “pydoc modules” Core Dump

By Xah Lee. Date:

On Ubuntu 12.04, when you do pydoc modules or help('modules') in Python shell, it core dumps.

◆ xah@xah-VB3◆ 2012-12-15 14:47 ◆ ~/git/ergoemacs
◆ python
Python 2.7.3 (default, Aug  1 2012, 05:16:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> help('modules')

Please wait a moment while I gather a list of all available modules...

/usr/lib/python2.7/dist-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
  import gobject._gobject
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
  from gtk import _gtk

** (python:8452): CRITICAL **: pyg_register_boxed: assertion `boxed_type != 0' failed
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: cannot register existing type `GdkDevice'
  from gtk import _gtk
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_type_get_qdata: assertion `node != NULL' failed
  from gtk import _gtk
Segmentation fault (core dumped)

One work-around is to: go to /usr/share/pyshared/gobject/constants.py and un-comment line # TYPE_INVALID defined in gobjectmodule.c

Before:

import gobject._gobject
_gobject = sys.modules['gobject._gobject']

# TYPE_INVALID defined in gobjectmodule.c
TYPE_NONE = _gobject.type_from_name('void')

After:

import gobject._gobject
_gobject = sys.modules['gobject._gobject']

TYPE_INVALID defined in gobjectmodule.c
TYPE_NONE = _gobject.type_from_name('void')

However, someone wrote it causes other crashes.

This bug is at least one year old. See: [Segmentation fault when asking help() for the list of modules By Onesandzeroes. At https://bugs.launchpad.net/ubuntu/+source/python2.7/+bug/896836 , accessed on 2012-12-15 ]. It's a show-stopped. Can't believe it's not fixed yet.

Not sure what's the fix. Maybe i should compile Python myself.

One solution is simply to install python3 and go with that. With that, you do pydoc3 modules.