From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28467 invoked by alias); 13 Nov 2012 18:53:11 -0000 Received: (qmail 28456 invoked by uid 22791); 13 Nov 2012 18:53:10 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS 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; Tue, 13 Nov 2012 18:53:03 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qADIr16A015268 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 13 Nov 2012 13:53:02 -0500 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qADIr0JJ031527 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Tue, 13 Nov 2012 13:53:01 -0500 From: Tom Tromey To: Cc: Subject: Re: [PATCH] Python 3 support, part 1 (non-testsuite part) References: <87mwyma6xi.fsf@fleche.redhat.com> Date: Tue, 13 Nov 2012 18:53:00 -0000 In-Reply-To: (Paul Koning's message of "Mon, 12 Nov 2012 21:37:18 +0000") Message-ID: <87390d8hdf.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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-11/txt/msg00329.txt.bz2 >>>>> "Paul" == writes: Paul> Because PyModule_Create returns a new reference, while Py_InitModule Paul> returns a borrowed reference (bletch). Oh, yeah, it is obvious now :) Thanks. [...] Paul> Or Py_TYPE (self)->tp_free (self) -- less change from the existing Paul> code. That argument doesn't need a cast, the signature is tp_free Paul> (void *). Oops, yeah, that is what I meant. Paul> + wchar_t *progname_copy; Tom> Can we really assume a working wchar_t? Paul> Yes, you'd expect a configure check or the like. But the header files Paul> for Python reference that type without any checks that I can see. Paul> Similarly mbstowcs(). It looks like you can't built Python 3 if those Paul> aren't defined (which makes some sense -- how else could you build a Paul> program that uses Unicode for all its strings?). Ok, I think that is sufficient. If Python ever adds checks, and we hit such a such a system, we can fix it up then. It is a little weird since wchar_t isn't guaranteed to have anything to do with Unicode. But I assume they know what they are doing. Paul> Ok. That code was adapted from Python 3 code which does it this way. Paul> The existing code in python.c calls a whole string of API calls (like Paul> PyModule_AddStringConstant) without checking the error status from any Paul> of them. Should I add those, with the failure action being to disable Paul> Python support in GDB? I'm not sure what to do about those. I guess failing gracefully would be better than what we do now. FWIW I'm not sure we really have a way to disable Python at runtime yet. And to be clear, I don't expect you to add this as part of your patch. Mostly I just want to avoid an 'exit' on a failure to initialize -- it is better for gdb to try to limp along in this situation. Paul> Index: py-inferior.c [...] Paul> GDB_PY_HANDLE_EXCEPTION (except); Paul> +#ifdef IS_PY3K Paul> + PyBuffer_Release (pybuf); Paul> +#endif GDB_PY_HANDLE_EXCEPTION can return, so cleaning up has to be handled there as well somehow. Maybe this is an issue in the other spot, too, I couldn't tell immediately. Tom