[RFC] Make python/lib/gdb and submodules proper Python modules

Khoo Yit Phang khooyp@cs.umd.edu
Mon Sep 3 03:44:00 GMT 2012


Hi,

I found it strange that python/lib/gdb and its submodules aren't truly Python modules (e.g., the python/lib/gdb/__init__.py had to explicitly refer to the gdb module), so I've put together a patch that makes them proper Python modules.

This patch works by splitting out the gdb module into _gdb for the native code extensions (as recommended by PEP8), setting up sys.path in finish_python_initialization and finally loading the gdb module, as well as switching from using exec to reload/__import__ (which updates/creates Python modules). Also, I've made a few other related changes: I removed gdb.PYTHONDIR which isn't necessary anymore since the same information is available via gdb.__file__, and moved the Python code from finish_python_initialization to python/lib/gdb/__init__.py.

One caveat about this patch is that the data-directory must contain the gdb module, otherwise Python will not be fully initialized (with a warning) and Python support will be very limited (only the _gdb module will be available).

I've ran the testsuite on Ubuntu 11.04 with Python 2.7.1 and Python 2.4.6 and found no regressions (you may need the patch I recently posted that adds -nx to a few tests to avoid spurious results).

What do you think?

Thanks,

Yit
September 2, 2012

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: python-gdb-native-module.txt
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20120903/23f281fc/attachment.txt>


More information about the Gdb-patches mailing list