From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by sourceware.org (Postfix) with ESMTPS id 9953C385841B for ; Thu, 13 Jan 2022 19:46:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9953C385841B Received: by mail-il1-x132.google.com with SMTP id a18so227516ilq.6 for ; Thu, 13 Jan 2022 11:46:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=bT+GVPzdDIoVqQb2BL9gPsyJ8YNCO0opNqsIKSbfSzU=; b=KfAIbCZNoVmuPKWZU52VdFwNuiaUb4OxHaGFdBDDUyhX7a3YDADntWoLVN1WNcZNEO p64WO7PUYqMfh9Ieue0H/V+oPo3GM1ooiLwcU6j4gA6MQrK5r8RxMs1kja4WeBDG6RGT yK0nOKRq+c5aEKN/ByKPOlxqLGszRKFixNugIQT8AwjIc4JyyeWqga/RAimZ6Db3CQmA 0+b2MrsnlKeim5XYn2bKVOovrsT/WsnHLDpxlRTzBJM7jJCDiRJ4qkyvOmO1czf90h8u BdO7WLAV5TelUeaWqjlzsNasiQFEJ/c5+mpwOQ+gY6d1kIdSQ2fH7FTD9+iHMBGXP9Fj 2Eng== X-Gm-Message-State: AOAM530+yahAVXYZaSVVL58p+RddYK1VMt64A4cSyTjxt5gLvGH+olML F5nihRGh8dAijOa4x8CiqEW11OekaMmu2Q== X-Google-Smtp-Source: ABdhPJya38MkyQPBe1wxdf7EwaUbGHJiJlYjcT0qUOhx0jMXIFMXhn+dyhrfdbtt4GpvLptBqDZqEA== X-Received: by 2002:a05:6e02:2162:: with SMTP id s2mr3045390ilv.323.1642103161914; Thu, 13 Jan 2022 11:46:01 -0800 (PST) Received: from murgatroyd (75-166-134-30.hlrn.qwest.net. [75.166.134.30]) by smtp.gmail.com with ESMTPSA id c1sm2865049ild.47.2022.01.13.11.46.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jan 2022 11:46:01 -0800 (PST) From: Tom Tromey To: Lancelot SIX Cc: Tom Tromey , gdb-patches@sourceware.org Subject: Re: [PATCH v2 3/3] Add a way to temporarily set a gdb parameter from Python References: <20220110215144.1714909-1-tromey@adacore.com> <20220110215144.1714909-4-tromey@adacore.com> <20220113085059.z3rm44jun2sconai@Plymouth> X-Attribution: Tom Date: Thu, 13 Jan 2022 12:46:00 -0700 In-Reply-To: <20220113085059.z3rm44jun2sconai@Plymouth> (Lancelot SIX's message of "Thu, 13 Jan 2022 08:50:59 +0000") Message-ID: <87r19bju6f.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Thu, 13 Jan 2022 19:46:05 -0000 Lancelot> try: Lancelot> yield Lancelot> finally: Lancelot> set_parameter(name, old_value) Lancelot> This way, the parameter is restored even in case of exception, which is Lancelot> what I would expect from a python user point of view. Yeah, thanks. I had assumed @contextmanager would handle this. Anyway I'll make this change. Tom