[patch] [libstdc++ pretty-printer] Fix python `dir' var vs. func clash
Jan Kratochvil
jan.kratochvil@redhat.com
Fri Aug 6 19:03:00 GMT 2010
Hi,
before loading stdc++ program:
(gdb) python print dir
<built-in function dir>
(gdb) python print dir()
['GdbOutputFile', '__builtins__', '__doc__', '__name__', '__package__', 'exists', 'gdb', 'ipy', 'sys']
after loading stdc++ program:
(gdb) python print dir
/usr/lib64/../share/gcc-4.5.0/python
(gdb) python print dir()
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: 'str' object is not callable
Error while executing Python code.
With the patch below after loading stdc++ program:
(gdb) python print dir
<built-in function dir>
(gdb) python print dir()
['GdbOutputFile', '__builtins__', '__doc__', '__name__', '__package__', 'dir_', 'dotdots', 'exists', 'gdb', 'ipy', 'libdir', 'objfile', 'os', 'prefix', 'pythondir', 'register_libstdcxx_printers', 'sys']
Probably obvious, OK to check-in?
Thanks,
Jan
libstdc++-v3/
2009-09-18 David Malcolm <dmalcolm@redhat.com>
Jan Kratochvil <jan.kratochvil@redhat.com>
* python/hook.in: Rename variable dir to dir_.
--- a/libstdc++-v3/python/hook.in
+++ b/libstdc++-v3/python/hook.in
@@ -50,10 +50,10 @@ if gdb.current_objfile () is not None:
dotdots = ('..' + os.sep) * len (libdir.split (os.sep))
objfile = gdb.current_objfile ().filename
- dir = os.path.join (os.path.dirname (objfile), dotdots, pythondir)
+ dir_ = os.path.join (os.path.dirname (objfile), dotdots, pythondir)
- if not dir in sys.path:
- sys.path.insert(0, dir)
+ if not dir_ in sys.path:
+ sys.path.insert(0, dir_)
# Load the pretty-printers.
from libstdcxx.v6.printers import register_libstdcxx_printers
More information about the Gcc-patches
mailing list