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

login
register
mail settings
Submitter Jan Kratochvil
Date Aug. 6, 2010, 7:02 p.m.
Message ID <20100806190251.GA9625@host1.dyn.jankratochvil.net>
Download mbox | patch
Permalink /patch/61131/
State New
Headers show

Comments

Jan Kratochvil - Aug. 6, 2010, 7:02 p.m.
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_.
Tom Tromey - Aug. 6, 2010, 8:26 p.m.
>>>>> "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.
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

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