From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22112 invoked by alias); 23 Nov 2016 22:40:36 -0000 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 Received: (qmail 22083 invoked by uid 89); 23 Nov 2016 22:40:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RCVD_IN_SORBS_SPAM,URIBL_RED autolearn=ham version=3.3.2 spammy=lgustavocodesourcerycom, Hx-languages-length:2205, lgustavo@codesourcery.com, U*lgustavo X-HELO: sasl.smtp.pobox.com Received: from pb-smtp2.pobox.com (HELO sasl.smtp.pobox.com) (64.147.108.71) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 Nov 2016 22:40:24 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 525B852750 for ; Wed, 23 Nov 2016 17:40:23 -0500 (EST) Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 4A6505274F for ; Wed, 23 Nov 2016 17:40:23 -0500 (EST) Received: from mail-io0-f169.google.com (unknown [209.85.223.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id B129D5274C for ; Wed, 23 Nov 2016 17:40:22 -0500 (EST) Received: by mail-io0-f169.google.com with SMTP id j65so49840601iof.0 for ; Wed, 23 Nov 2016 14:40:21 -0800 (PST) X-Gm-Message-State: AKaTC01mfxVgffYGzYSSwHEGYcITeO2/GUN4nVU7702odNp+61RqDhi37i3m9xaV+1i4g3EezW18oe7mg0kHWg== X-Received: by 10.36.8.5 with SMTP id 5mr5194617itc.73.1479940821458; Wed, 23 Nov 2016 14:40:21 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.156.67 with HTTP; Wed, 23 Nov 2016 14:39:41 -0800 (PST) In-Reply-To: References: <20161120204526.7203-1-jonah@kichwacoders.com> From: Jonah Graham Date: Wed, 23 Nov 2016 22:40:00 -0000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] bound_registers.py: Add support for Python 3 To: Luis Machado Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=UTF-8 X-Pobox-Relay-ID: D1C8CD62-B1CD-11E6-9FED-B2917B1B28F4-18936988!pb-smtp2.pobox.com X-IsSubscribed: yes X-SW-Source: 2016-11/txt/msg00731.txt.bz2 On 23 November 2016 at 16:59, Luis Machado wrote: > On 11/20/2016 02:45 PM, Jonah Graham wrote: >> >> gdb/Changelog: >> >> * python/lib/gdb/printer/bound_registers.py: Add support >> for Python 3. >> --- >> gdb/ChangeLog | 5 +++++ >> gdb/python/lib/gdb/printer/bound_registers.py | 5 +++++ >> 2 files changed, 10 insertions(+) >> >> diff --git a/gdb/ChangeLog b/gdb/ChangeLog >> index 3797e8b..1923888 100644 >> --- a/gdb/ChangeLog >> +++ b/gdb/ChangeLog >> @@ -1,3 +1,8 @@ >> +2016-11-20 Jonah Graham >> + >> + * python/lib/gdb/printer/bound_registers.py: Add support >> + for Python 3. >> + >> 2016-11-19 Joel Brobecker >> >> * contrib/ari/gdb_ari.sh: Add detection of printf_vma and >> diff --git a/gdb/python/lib/gdb/printer/bound_registers.py >> b/gdb/python/lib/gdb/printer/bound_registers.py >> index 9ff94aa..e91cc19 100644 >> --- a/gdb/python/lib/gdb/printer/bound_registers.py >> +++ b/gdb/python/lib/gdb/printer/bound_registers.py >> @@ -16,6 +16,11 @@ >> >> import gdb.printing >> >> +if sys.version_info[0] > 2: >> + # Python 3 removed basestring and long >> + basestring = str >> + long = int >> + >> class MpxBound128Printer: >> """Adds size field to a mpx __gdb_builtin_type_bound128 type.""" >> >> > > Since this should apply to every python module, maybe this should be defined > inside gdb/python/lib/gdb/__init__.py? > > I'm assuming it gets included by module "gdb" and therefore "long" is > defined to be "int" for Python versions > 3. > > Then we can remove that code from gdb/python/lib/gdb/printing.py (and from > other places setting this type of version-specific adjustment). > > Does that make sense? Hi Luis, I am not sure I understand how to do it in __init__.py as the modules that wanted to be both Python 2 and Python 3 compatible would still have to have special code. AFAIK an __init__.py cannot change the value of long in other py files. So python/lib/gdb/printing.py and python/lib/gdb/printer/bound_registers.py would still need special case code locally, even if that special case was an import for a definition of long. Jonah