From patchwork Fri Aug 6 19:02:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 61131 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 9ECADB6EFE for ; Sat, 7 Aug 2010 05:03:07 +1000 (EST) Received: (qmail 30350 invoked by alias); 6 Aug 2010 19:03:05 -0000 Received: (qmail 30216 invoked by uid 22791); 6 Aug 2010 19:03:04 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_BJ, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 06 Aug 2010 19:02:56 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o76J2tRD020936 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 6 Aug 2010 15:02:55 -0400 Received: from host1.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o76J2qCT021126 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 6 Aug 2010 15:02:54 -0400 Received: from host1.dyn.jankratochvil.net (localhost [127.0.0.1]) by host1.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id o76J2q3e010894; Fri, 6 Aug 2010 21:02:52 +0200 Received: (from jkratoch@localhost) by host1.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id o76J2p3k010893; Fri, 6 Aug 2010 21:02:51 +0200 Date: Fri, 6 Aug 2010 21:02:51 +0200 From: Jan Kratochvil To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [patch] [libstdc++ pretty-printer] Fix python `dir' var vs. func clash Message-ID: <20100806190251.GA9625@host1.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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