* [PATCH] [gdb/dap] Fix dap for python < 3.8
@ 2023-09-26 11:21 Tom de Vries
2023-09-26 13:40 ` Tom Tromey
0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2023-09-26 11:21 UTC (permalink / raw)
To: gdb-patches
With any gdb.dap test and python 3.6 I run into:
...
Error occurred in Python: 'code' object has no attribute 'co_posonlyargcount'
ERROR: eof reading json header
...
The attribute is not supported before python 3.8, which introduced the
"Positional−only Parameters" concept.
Fix this by using try/except AttributeError.
Tested on x86_64-linux:
- openSUSE Leap 15.4 with python 3.6, and
- openSUSE Tumbleweed with python 3.11.5.
---
gdb/python/lib/gdb/dap/server.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/gdb/python/lib/gdb/dap/server.py b/gdb/python/lib/gdb/dap/server.py
index d84bca5d1fc..62bf240c1e9 100644
--- a/gdb/python/lib/gdb/dap/server.py
+++ b/gdb/python/lib/gdb/dap/server.py
@@ -168,7 +168,11 @@ def request(name):
global _commands
code = func.__code__
# We don't permit requests to have positional arguments.
- assert code.co_posonlyargcount == 0
+ try:
+ assert code.co_posonlyargcount == 0
+ except AttributeError:
+ # Attribute co_posonlyargcount is supported starting python 3.8.
+ pass
assert code.co_argcount == 0
# A request must have a **args parameter.
assert code.co_flags & inspect.CO_VARKEYWORDS
base-commit: 5437a944648eef989f8ecde29787d7924b80fdc0
--
2.35.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] [gdb/dap] Fix dap for python < 3.8
2023-09-26 11:21 [PATCH] [gdb/dap] Fix dap for python < 3.8 Tom de Vries
@ 2023-09-26 13:40 ` Tom Tromey
0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2023-09-26 13:40 UTC (permalink / raw)
To: Tom de Vries via Gdb-patches; +Cc: Tom de Vries
>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
Tom> With any gdb.dap test and python 3.6 I run into:
Tom> ...
Tom> Error occurred in Python: 'code' object has no attribute 'co_posonlyargcount'
Tom> ERROR: eof reading json header
Tom> ...
Tom> The attribute is not supported before python 3.8, which introduced the
Tom> "Positional−only Parameters" concept.
Tom> Fix this by using try/except AttributeError.
Thank you.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-09-26 13:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-26 11:21 [PATCH] [gdb/dap] Fix dap for python < 3.8 Tom de Vries
2023-09-26 13:40 ` Tom Tromey
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).