diff mbox

[libstdc++,pretty-printer] Fix python `dir' var vs. func clash

Message ID 20100806190251.GA9625@host1.dyn.jankratochvil.net
State New
Headers show

Commit Message

Jan Kratochvil Aug. 6, 2010, 7:02 p.m. UTC
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_.

Comments

Tom Tromey Aug. 6, 2010, 8:26 p.m. UTC | #1
>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:

Jan> Probably obvious, OK to check-in?

Jan> libstdc++-v3/
Jan> 2009-09-18  David Malcolm  <dmalcolm@redhat.com>
Jan>             Jan Kratochvil  <jan.kratochvil@redhat.com>
Jan> 	* python/hook.in: Rename variable dir to dir_.

This is ok.  Thanks.

Tom
Jan Kratochvil Aug. 6, 2010, 8:44 p.m. UTC | #2
On Fri, 06 Aug 2010 22:26:00 +0200, Tom Tromey wrote:
> >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
> Jan> libstdc++-v3/
> Jan> 2009-09-18  David Malcolm  <dmalcolm@redhat.com>
> Jan>             Jan Kratochvil  <jan.kratochvil@redhat.com>
> Jan> 	* python/hook.in: Rename variable dir to dir_.
> 
> This is ok.  Thanks.

Checked-in:
	http://gcc.gnu.org/viewcvs?view=revision&revision=162962


Thanks,
Jan
diff mbox

Patch

--- 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