forked from Imagelibrary/binutils-gdb
[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
...
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import queue
|
import queue
|
||||||
|
import sys
|
||||||
|
|
||||||
from .io import start_json_writer, read_json
|
from .io import start_json_writer, read_json
|
||||||
from .startup import (
|
from .startup import (
|
||||||
@@ -47,6 +48,9 @@ class Server:
|
|||||||
# This queue accepts JSON objects that are then sent to the
|
# This queue accepts JSON objects that are then sent to the
|
||||||
# DAP client. Writing is done in a separate thread to avoid
|
# DAP client. Writing is done in a separate thread to avoid
|
||||||
# blocking the read loop.
|
# blocking the read loop.
|
||||||
|
if sys.version_info[0] == 3 and sys.version_info[1] <= 6:
|
||||||
|
self.write_queue = queue.Queue()
|
||||||
|
else:
|
||||||
self.write_queue = queue.SimpleQueue()
|
self.write_queue = queue.SimpleQueue()
|
||||||
self.done = False
|
self.done = False
|
||||||
global _server
|
global _server
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import signal
|
|||||||
import threading
|
import threading
|
||||||
import traceback
|
import traceback
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
# The GDB thread, aka the main thread.
|
# The GDB thread, aka the main thread.
|
||||||
@@ -173,6 +174,9 @@ def send_gdb_with_response(fn):
|
|||||||
"""
|
"""
|
||||||
if isinstance(fn, str):
|
if isinstance(fn, str):
|
||||||
fn = Invoker(fn)
|
fn = Invoker(fn)
|
||||||
|
if sys.version_info[0] == 3 and sys.version_info[1] <= 6:
|
||||||
|
result_q = queue.Queue()
|
||||||
|
else:
|
||||||
result_q = queue.SimpleQueue()
|
result_q = queue.SimpleQueue()
|
||||||
|
|
||||||
def message():
|
def message():
|
||||||
|
|||||||
Reference in New Issue
Block a user