public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] [gdb/python] Avoid queue.SimpleQueue for python 3.6
@ 2023-01-05 16:35 Tom de Vries
0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2023-01-05 16:35 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=954a1f9183c68671c07f21baf78ac2053390af55
commit 954a1f9183c68671c07f21baf78ac2053390af55
Author: Tom de Vries <tdevries@suse.de>
Date: Thu Jan 5 17:35:41 2023 +0100
[gdb/python] Avoid queue.SimpleQueue for python 3.6
On openSUSE Leap 15.4 with python 3.6, the gdb.dap/basic-dap.exp test-case
fails as follows:
...
ERROR: eof reading json header
while executing
"error "eof reading json header""
invoked from within
"expect {
-i exp19 -timeout 10
-re "^Content-Length: (\[0-9\]+)\r\n" {
set length $expect_out(1,string)
exp_continue
}
-re "^(\[^\r\n\]+)..."
("uplevel" body line 1)
invoked from within
"uplevel $body" NONE eof reading json header
UNRESOLVED: gdb.dap/basic-dap.exp: startup - initialize
...
Investigation using a "catch throw" shows that:
...
(gdb)
at gdb/python/py-utils.c:396
396 error (_("Error occurred in Python: %s"), msg.get ());
(gdb) p msg.get ()
$1 = 0x2b91d10 "module 'queue' has no attribute 'SimpleQueue'"
...
The python class queue.SimpleQueue was introduced in python 3.7.
Fix this by falling back to queue.Queue for python <= 3.6.
Tested on x86_64-linux, by successfully running the test-case:
...
# of expected passes 47
...
Diff:
---
gdb/python/lib/gdb/dap/server.py | 6 +++++-
gdb/python/lib/gdb/dap/startup.py | 6 +++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/gdb/python/lib/gdb/dap/server.py b/gdb/python/lib/gdb/dap/server.py
index d6fc0bd5754..f8cb6170a96 100644
--- a/gdb/python/lib/gdb/dap/server.py
+++ b/gdb/python/lib/gdb/dap/server.py
@@ -15,6 +15,7 @@
import json
import queue
+import sys
from .io import start_json_writer, read_json
from .startup import (
@@ -47,7 +48,10 @@ class Server:
# This queue accepts JSON objects that are then sent to the
# DAP client. Writing is done in a separate thread to avoid
# blocking the read loop.
- self.write_queue = queue.SimpleQueue()
+ if sys.version_info[0] == 3 and sys.version_info[1] <= 6:
+ self.write_queue = queue.Queue()
+ else:
+ self.write_queue = queue.SimpleQueue()
self.done = False
global _server
_server = self
diff --git a/gdb/python/lib/gdb/dap/startup.py b/gdb/python/lib/gdb/dap/startup.py
index acfdcb4d81b..523705a5933 100644
--- a/gdb/python/lib/gdb/dap/startup.py
+++ b/gdb/python/lib/gdb/dap/startup.py
@@ -22,6 +22,7 @@ import signal
import threading
import traceback
from contextlib import contextmanager
+import sys
# The GDB thread, aka the main thread.
@@ -173,7 +174,10 @@ def send_gdb_with_response(fn):
"""
if isinstance(fn, str):
fn = Invoker(fn)
- result_q = queue.SimpleQueue()
+ if sys.version_info[0] == 3 and sys.version_info[1] <= 6:
+ result_q = queue.Queue()
+ else:
+ result_q = queue.SimpleQueue()
def message():
try:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-01-05 16:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05 16:35 [binutils-gdb] [gdb/python] Avoid queue.SimpleQueue for python 3.6 Tom de Vries
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).