From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id GHnsLFhwVGEFMAAAWB0awg (envelope-from ) for ; Wed, 29 Sep 2021 09:55:36 -0400 Received: by simark.ca (Postfix, from userid 112) id B59A51EE27; Wed, 29 Sep 2021 09:55:36 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id F25C31EE24 for ; Wed, 29 Sep 2021 09:55:35 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9ECD13857C40 for ; Wed, 29 Sep 2021 13:55:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9ECD13857C40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1632923735; bh=4tCmUx3ndDtmh07u7992x3pffMLZVJPNdEpw4dhJAJw=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=CeFL9w8kc8pTCLb25j7VXRSJhny+T7GKlCA6npaGLDUnXFQGsRlCyqOXijItPyLCI vQk9chcPn8ySsjZrj19/Cwl5A+bMoQ8wjs7Tm5DngbAaMnMeqFKqaPsF2LjePyQdsj UyS1LBiCrFfQnEApMA02307hmyCkFmrlqRBtpvmc= Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 64533385802D for ; Wed, 29 Sep 2021 13:55:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 64533385802D Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 9CAA71FDE2 for ; Wed, 29 Sep 2021 13:55:07 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 89AEF14027 for ; Wed, 29 Sep 2021 13:55:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id oHlEIDtwVGHtYAAAMHmgww (envelope-from ) for ; Wed, 29 Sep 2021 13:55:07 +0000 Date: Wed, 29 Sep 2021 15:55:05 +0200 To: gdb-patches@sourceware.org Subject: [committed][gdb/testsuite] Fix gdb.python/py-breakpoint.exp with python 2 Message-ID: <20210929135503.GA16072@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hi, With a gdb build using python 2.7, I run into: ... (gdb) python \ gdb.events.breakpoint_modified.connect(lambda bp: print(bp.enabled))^M File "", line 1^M gdb.events.breakpoint_modified.connect(lambda bp: print(bp.enabled))^M ^^M SyntaxError: invalid syntax^M Error while executing Python code.^M (gdb) FAIL: gdb.python/py-breakpoint.exp: test_bkpt_auto_disable: \ trap breakpoint_modified event ... This is caused by the following: - a lambda function body needs to be an expression - in python 2, print is a statement, while in python 3 it's a function - a function call is an expression, and a statement is not. Fix this by defining a function print_bp_enabled: ... def print_bp_enabled (bp): print (bp.enabled) end ... and using that instead. Tested on x86_64-linux. Committed to trunk. Thanks, - Tom [gdb/testsuite] Fix gdb.python/py-breakpoint.exp with python 2 --- gdb/testsuite/gdb.python/py-breakpoint.exp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp index 857480d4b61..bd99452dd5f 100644 --- a/gdb/testsuite/gdb.python/py-breakpoint.exp +++ b/gdb/testsuite/gdb.python/py-breakpoint.exp @@ -816,7 +816,15 @@ proc_with_prefix test_bkpt_auto_disable { } { set mult_line [gdb_get_line_number "Break at multiply."] gdb_breakpoint ${mult_line} gdb_test_no_output "enable count 1 2" "one shot enable" - gdb_test_no_output "python gdb.events.breakpoint_modified.connect(lambda bp: print(bp.enabled))" \ + # Python 2 doesn't support print in lambda function, so use a named + # function instead. + gdb_test_multiline "Define print_bp_enabled" \ + "python" "" \ + "def print_bp_enabled (bp):" "" \ + " print (bp.enabled)" "" \ + "end" "" + gdb_test_no_output \ + "python gdb.events.breakpoint_modified.connect(print_bp_enabled)" \ "trap breakpoint_modified event" gdb_test "continue" "False.*" "auto-disabling after enable count reached" }