Remove f-strings from DAP
authorTom Tromey <tromey@adacore.com>
Fri, 2 Jun 2023 15:43:01 +0000 (09:43 -0600)
committerTom Tromey <tromey@adacore.com>
Mon, 12 Jun 2023 18:24:07 +0000 (12:24 -0600)
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
gdb/python/lib/gdb/dap/io.py
gdb/python/lib/gdb/dap/launch.py
gdb/python/lib/gdb/dap/state.py

index 2b400651b67ec463e98ddf62f203f45149b44b75..af7bf43afd0e135f0107d275c3764258c40d0510 100644 (file)
@@ -84,7 +84,7 @@ def eval_request(
     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
index 7cec7b032e3c12438b5073743c8d803ed14bbe0b..2f3a2351925191f5b2df1fb073e9d08ce0ebdcf8 100644 (file)
@@ -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)
index aee8c2f9ae6dc000589a5684bbfbc83e106dafa3..c3c09bc3dd09deaa741891d207beec60e2a07f8f 100644 (file)
@@ -59,7 +59,7 @@ def launch(
     if program is not None:
         global _program
         _program = program
-        send_gdb(f"file {_program}")
+        send_gdb("file " + _program)
     if stopAtBeginningOfMainSubprogram:
         send_gdb(_break_at_main)
     if len(args) > 0 or env is not None:
index caf654aaf07ac983977c95ac353210936fa3a0c8..f4f81d2afa06acf4d2d21a5acd9504b18a59c07e 100644 (file)
@@ -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))