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

Tom Tromey
2012-09-10T20:38:20Z

>>>>> "Yit" == Khoo Yit Phang <khooyp@cs.umd.edu> writes:

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

Seems reasonable to me. Thanks.

Yit> Also, I've made a few other related
Yit> changes: I removed gdb.PYTHONDIR which isn't necessary anymore since
Yit> the same information is available via gdb.__file__, and moved the
Yit> Python code from finish_python_initialization to
Yit> python/lib/gdb/__init__.py.

I think it would be good to restore this, as Doug said.
I realize Python programs can adapt, but it is friendlier not to make
them adapt.

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

I think this is probably ok.

Yit> + if (gdb_python_module && PyObject_HasAttrString (gdb_python_module, "prompt_hook"))

This line should probably split before the "&&".

Tom