From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26663 invoked by alias); 7 Sep 2012 06:19:12 -0000 Received: (qmail 26653 invoked by uid 22791); 7 Sep 2012 06:19:10 -0000 X-SWARE-Spam-Status: No, hits=-5.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-vb0-f41.google.com (HELO mail-vb0-f41.google.com) (209.85.212.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 07 Sep 2012 06:18:58 +0000 Received: by vbkv13 with SMTP id v13so3028217vbk.0 for ; Thu, 06 Sep 2012 23:18:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:x-system-of-record:x-gm-message-state; bh=VZzBzhCpZQjqQ0tSA8fVsLFG3Ly1OQKfbt8zgWK/qcA=; b=koz7OoSP3TG2O994qePMhH3YtPpUecmImntASujfqf95Uew6oxq5XLxeewgHQPkp/+ wVGzXYt7f7AsjZFbrMQFQ60RxSXTDECfx/uYuGkCCGMlsOjqGXYXntHPbg0+8dfkL3/b FcbVipGH8yd+HkdlZrNsdGhgFpZCzsUk9SCWm9HAFXxwi2/ovocj8CN4pzZV/L1JS6m9 mA/+P24JgkIAWWhhz1SiuB69PGGmdvGXDk6dr4PEjdTG1Gcd8tpn5K9I928Y3dJiKEe2 AfGQrNJfpPwP0t76KNFHk9B0dSyIyfTNxT3G94JJNeRcXXNzM+ekq0BYQsxLH8a0Vd9E HQuA== Received: by 10.52.34.212 with SMTP id b20mr4641677vdj.115.1346998737521; Thu, 06 Sep 2012 23:18:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.34.212 with SMTP id b20mr4641662vdj.115.1346998737348; Thu, 06 Sep 2012 23:18:57 -0700 (PDT) Received: by 10.52.24.239 with HTTP; Thu, 6 Sep 2012 23:18:57 -0700 (PDT) In-Reply-To: References: Date: Fri, 07 Sep 2012 06:19:00 -0000 Message-ID: Subject: Re: [RFC] Make python/lib/gdb and submodules proper Python modules From: Doug Evans To: Khoo Yit Phang Cc: GDB Patches Content-Type: text/plain; charset=ISO-8859-1 X-System-Of-Record: true X-Gm-Message-State: ALoCoQnHzVV5S4/lCRYjAc6+MFq7inbJ1UZCEAFE0gJJA8Gt9rKUECHTUSIZy7Pnb+t2cU41w5QkHsKCPHug97sIktw/dzvGt3SXTnXb0Je0zj+DbltiXO5pkx5Hi5lFvi6UqXtekLYMNiDWkawL8efqm2fam5oN2jHHlHIk8KTp/S6oa7XyrUMgDM6QutF7cBsec71hVtuyQYsZO9SKgUuTKzmYJucxJg== X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-09/txt/msg00055.txt.bz2 Oh bother, sorry for the resend. On Sun, Sep 2, 2012 at 8:44 PM, Khoo Yit Phang wrote: > > Hi, > > I found it strange that python/lib/gdb and its submodules aren't truly > Python modules (e.g., the python/lib/gdb/__init__.py had to explicitly refer > to the gdb module), so I've put together a patch that makes them proper > Python modules. > > This patch works by splitting out the gdb module into _gdb for the native > code extensions (as recommended by PEP8), setting up sys.path in > finish_python_initialization and finally loading the gdb module, as well as > switching from using exec to reload/__import__ (which updates/creates Python > modules). Also, I've made a few other related changes: I removed > gdb.PYTHONDIR which isn't necessary anymore since the same information is > available via gdb.__file__, and moved the Python code from > finish_python_initialization to python/lib/gdb/__init__.py. > > One caveat about this patch is that the data-directory must contain the > gdb module, otherwise Python will not be fully initialized (with a warning) > and Python support will be very limited (only the _gdb module will be > available). > > I've ran the testsuite on Ubuntu 11.04 with Python 2.7.1 and Python 2.4.6 > and found no regressions (you may need the patch I recently posted that adds > -nx to a few tests to avoid spurious results). Hi. One thing that comes to mind is that, regardless of implementation details, we can't easily get rid of gdb.PYTHONDIR because it's part of the API gdb provides. [grep PYTHONDIR doc/gdb.texinfo]