From patchwork Fri Jun 2 15:45:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 70537 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 60869385B532 for ; Fri, 2 Jun 2023 15:45:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 60869385B532 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685720735; bh=seaux9ATIoOeJBOf+AdCw7CDtZTJ6r9+BI6GTQD2hqk=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=ecOlKGQIfswk0VqyEHIIso26B0AyQlrPWlfsLxxOlpGQXp2+eGImoJSGQqrFubrc5 qtV3LJmZOh9By9NBfYeudOJC61jA97kF/rXCA+58wBV/bTC6TbS37btxZKyEgFh4wI WvyC9xWBiz3L97p2QS+tTl90X04H8hiblgPDPPDE= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by sourceware.org (Postfix) with ESMTPS id 857D8385C6FF for ; Fri, 2 Jun 2023 15:45:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 857D8385C6FF Received: by mail-il1-x12b.google.com with SMTP id e9e14a558f8ab-33b3674acdeso11493905ab.1 for ; Fri, 02 Jun 2023 08:45:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685720710; x=1688312710; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=seaux9ATIoOeJBOf+AdCw7CDtZTJ6r9+BI6GTQD2hqk=; b=P2YXNPO0YrPhZlqdwYymy/3+W7LaQJLul/n3t/2lNBxZ9p9DtieqcFXbaat2PXs9Wm Hi0qLv6iXOmh+W1AnRBd4Nmx0VUFvSuEBozay7eM+BnFzty0gWhsLx1w8ESahhw+v4/c rI8f8Nl1Gv56iFQvgHc3T9jB0GBiOVtPnjOpiwTYgGFWtefbculu1VjnpKxTTnSrCSIa MoUvQ03Oa0uFEaWzfreBz9PbNEdmOymSDMBx02lEij0apVAWvwQ4CR5MB/0MLhjzSZ5G fhBQgKPksw47jy5FyH/9U8pKZIlBmp4Vszu/fa0d6N6a8qWWSZEgjHhok/dVc+9Y5Gxg hQ4A== X-Gm-Message-State: AC+VfDxCAFh/I1PmJ7iK9DBJcsCCa+pWM9aPPO70JqPs4Nw7oQaseKot Q5JZIaJWZf1aYGuB3PA/JQm3Iij7cziTOdliuw3OTQ== X-Google-Smtp-Source: ACHHUZ6BKQXPCHalYqJ0ulgl0QYsM3eJa4eOYIvymboTc2cOQeNs9IsB1M6i3wpF9OsGwnuPnKIuLw== X-Received: by 2002:a05:6e02:13d2:b0:338:1382:ad12 with SMTP id v18-20020a056e0213d200b003381382ad12mr4023124ilj.11.1685720710707; Fri, 02 Jun 2023 08:45:10 -0700 (PDT) Received: from localhost.localdomain (71-211-130-244.hlrn.qwest.net. [71.211.130.244]) by smtp.gmail.com with ESMTPSA id cu8-20020a05663848c800b0041cd626ea0csm357732jab.147.2023.06.02.08.45.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jun 2023 08:45:10 -0700 (PDT) To: gdb-patches@sourceware.org Cc: legouguec@adacore.com, Tom Tromey Subject: [PATCH] Remove f-strings from DAP Date: Fri, 2 Jun 2023 09:45:00 -0600 Message-Id: <20230602154500.3941614-1-tromey@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Tom Tromey via Gdb-patches From: Tom Tromey Reply-To: Tom Tromey Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Kévin pointed out that gdb claims a minimum Python version of 3.2, but the DAP code uses f-strings, which were added in 3.6. This patch removes the uses of f-strings from the DAP code. I can't test an older version of Python, but I did confirm that this still works with the version I have. --- gdb/python/lib/gdb/dap/evaluate.py | 2 +- gdb/python/lib/gdb/dap/io.py | 2 +- gdb/python/lib/gdb/dap/launch.py | 2 +- gdb/python/lib/gdb/dap/state.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gdb/python/lib/gdb/dap/evaluate.py b/gdb/python/lib/gdb/dap/evaluate.py index fffd255417b..7c4fee4f84b 100644 --- a/gdb/python/lib/gdb/dap/evaluate.py +++ b/gdb/python/lib/gdb/dap/evaluate.py @@ -62,7 +62,7 @@ def eval_request(*, expression, frameId=None, context="variables", **args): elif context == "repl": return send_gdb_with_response(lambda: _repl(expression, frameId)) else: - raise Exception(f'unknown evaluate context "{context}"') + raise Exception("unknown evaluate context " + context) @in_gdb_thread diff --git a/gdb/python/lib/gdb/dap/io.py b/gdb/python/lib/gdb/dap/io.py index 7cec7b032e3..2f3a2351925 100644 --- a/gdb/python/lib/gdb/dap/io.py +++ b/gdb/python/lib/gdb/dap/io.py @@ -60,7 +60,7 @@ def start_json_writer(stream, queue): seq = seq + 1 encoded = json.dumps(obj) body_bytes = encoded.encode("utf-8") - header = f"Content-Length: {len(body_bytes)}\r\n\r\n" + header = "Content-Length: " + str(len(body_bytes)) + "\r\n\r\n" header_bytes = header.encode("ASCII") stream.write(header_bytes) stream.write(body_bytes) diff --git a/gdb/python/lib/gdb/dap/launch.py b/gdb/python/lib/gdb/dap/launch.py index 21499a339e1..428fd811471 100644 --- a/gdb/python/lib/gdb/dap/launch.py +++ b/gdb/python/lib/gdb/dap/launch.py @@ -40,7 +40,7 @@ def launch(*, program=None, args=[], env=None, **extra): if program is not None: global _program _program = program - send_gdb(f"file {_program}") + send_gdb("file " + _program) if len(args) > 0 or env is not None: send_gdb(lambda: _set_args_env(args, env)) diff --git a/gdb/python/lib/gdb/dap/state.py b/gdb/python/lib/gdb/dap/state.py index caf654aaf07..f4f81d2afa0 100644 --- a/gdb/python/lib/gdb/dap/state.py +++ b/gdb/python/lib/gdb/dap/state.py @@ -22,4 +22,4 @@ def set_thread(thread_id): if thread_id == 0: log("+++ Thread == 0 +++") else: - exec_and_log(f"thread {thread_id}") + exec_and_log("thread " + str(thread_id))