From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 4E50E3858D28 for ; Thu, 19 Jan 2023 08:23:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4E50E3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674116616; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qgKwoG8dmKG6B4d4pI7k7KEan5lz+JDvogeZ1LZRP+w=; b=ImW4yTdBXGuP/09pPmDaVhKRIONxtQbwJ9hILBY+x1npI7QDoVrp8sfxgu2IHwqPyxk/De gE9sj2qyUv2/kyG0/bDeNNzPcMUm50Jjd98823qwqvHnwFbpxYxVD4bli9z6DcuwUZoIKa K1aLVqFm+UTrfMGhhBZMKBwcICBnZvE= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-377-yjq7re9ONVOYZRUBo6WFEA-1; Thu, 19 Jan 2023 03:23:35 -0500 X-MC-Unique: yjq7re9ONVOYZRUBo6WFEA-1 Received: by mail-qt1-f200.google.com with SMTP id q26-20020ac8735a000000b003b63165d87cso602253qtp.11 for ; Thu, 19 Jan 2023 00:23:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qgKwoG8dmKG6B4d4pI7k7KEan5lz+JDvogeZ1LZRP+w=; b=KXZ1OGydgORlRUjwYYcBOQ1lOYyR07A0uxqxQFEw6hVRv4s5rZ7BRVKUwKV0TPeP4d 1tHaWSFUteqd3VgZ0T/ttXHVK4QrBsZHHGbzZK/445iXK1L0X6sfv6RDLqqakwfL2t8f BT/poAgxvcyDGFyVU0bwjqNkjRs+hfKT1NmOAjINTyBZTkhjFxtn1iA7nXGJqjwoteJ9 RDxkTEPSJUH7MM18uk8EHf/N39+6eDbwm8JlCGAfAueLbRSQhrMKHCH7ciZAwZmzKjDN ntpT6tJpzyJK4DC4d9azakUgSnRHV8r3qs407IhPybWZPTRedRFWua7odU9YZ5U4cujv GhTg== X-Gm-Message-State: AFqh2kq8pSANdMCqU3jxnkvUmXFkJAhaGwaQVkxp5zPpXH/Bd3qKQRns FhvqR9otgjek6GRhLf/pAtSQrkARnHJ8OzS+RbfmoDt/EZ5W+Qoukx0Aep28AurBRnSBygV3Vz2 rMTnRxmvvb2KCo3TYkdbgJA== X-Received: by 2002:ac8:12c2:0:b0:3ab:8c3f:328b with SMTP id b2-20020ac812c2000000b003ab8c3f328bmr13419914qtj.4.1674116614721; Thu, 19 Jan 2023 00:23:34 -0800 (PST) X-Google-Smtp-Source: AMrXdXvQqr+wGMaJGi0YeqnDUqDFZ5WPrgqqVRnK4JLK14xP3O8b/fw6JlhaZHfjfYGj2ngfI87vVQ== X-Received: by 2002:ac8:12c2:0:b0:3ab:8c3f:328b with SMTP id b2-20020ac812c2000000b003ab8c3f328bmr13419899qtj.4.1674116614501; Thu, 19 Jan 2023 00:23:34 -0800 (PST) Received: from [192.168.0.45] (ip-62-245-66-121.bb.vodafone.cz. [62.245.66.121]) by smtp.gmail.com with ESMTPSA id y18-20020ac87092000000b003b2685a575asm9528010qto.21.2023.01.19.00.23.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Jan 2023 00:23:34 -0800 (PST) Message-ID: Date: Thu, 19 Jan 2023 09:23:31 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH] Add __repr__() implementation to a few Python types To: Andrew Burgess , Matheus Branco Borella via Gdb-patches Cc: Matheus Branco Borella References: <20230111003510.620-1-dark.ryu.550@gmail.com> <87wn5jen5t.fsf@redhat.com> From: Bruno Larsen In-Reply-To: <87wn5jen5t.fsf@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 18/01/2023 19:02, Andrew Burgess via Gdb-patches wrote: >> --- a/gdb/testsuite/gdb.python/py-arch.exp >> +++ b/gdb/testsuite/gdb.python/py-arch.exp >> @@ -29,6 +29,8 @@ if ![runto_main] { >> # Test python/15461. Invalid architectures should not trigger an >> # internal GDB assert. >> gdb_py_test_silent_cmd "python empty = gdb.Architecture()" "get empty arch" 0 >> +gdb_test "python print(repr (empty))" "" \ >> + "Test empty achitecture __repr__ does not trigger an assert" > I guess I was surprised that so many of the new tests included an > explicit call to repr, given the premise of the change was that simply > 'print(empty)' would now print something useful. > > I guess maybe it doesn't hurt to_also_ include some explicit repr > calls, but I was expecting most tests to just be printing the object > directly. > > Is there some reasoning here that I'm missing? > When you make a print(empty) call, python internally calls __str__ instead or __repr__. The latter is only called when the former is not available or when it is being printed by the interpreter. Since py-type.c already includes a __str__ implementation, the test would still pass if you just had print(empty) without Matheus's changes. -- Cheers, Bruno