From patchwork Fri Aug 6 19:02:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [libstdc++,pretty-printer] Fix python `dir' var vs. func clash Date: Fri, 06 Aug 2010 09:02:51 -0000 From: Jan Kratochvil X-Patchwork-Id: 61131 Message-Id: <20100806190251.GA9625@host1.dyn.jankratochvil.net> To: gcc-patches@gcc.gnu.org Cc: David Malcolm Hi, before loading stdc++ program: (gdb) python print 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 "", line 1, in TypeError: 'str' object is not callable Error while executing Python code. With the patch below after loading stdc++ program: (gdb) python print 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 Jan Kratochvil * 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