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

Doug Evans
2012-09-07T06:19:12Z

Oh bother, sorry for the resend.

On Sun, Sep 2, 2012 at 8:44 PM, Khoo Yit Phang <khooyp@cs.umd.edu> wrote:
>
> 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).

Hi.
One thing that comes to mind is that, regardless of implementation
details, we can't easily get rid of gdb.PYTHONDIR because it's part of
the API gdb provides.
[grep PYTHONDIR doc/gdb.texinfo]