Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP7:GA
gdb.27039
gdb-testsuite-handle-older-python-in-gdb.python...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File gdb-testsuite-handle-older-python-in-gdb.python-py-send-packet.py.patch of Package gdb.27039
[gdb/testsuite] Handle older python in gdb.python/py-send-packet.py With python 3.4, I run into: ... Traceback (most recent call last):^M File "<string>", line 1, in <module>^M File "outputs/gdb.python/py-send-packet/py-send-packet.py", line 128, in \ run_set_global_var_test^M res = conn.send_packet(b"X%x,4:\x02\x02\x02\x02" % addr)^M TypeError: Could not convert Python object: b'X%x,4:\x02\x02\x02\x02'.^M Error while executing Python code.^M ... while with python 3.6 this works fine. Fix this by avoiding the byte literal (with prefix b), and use instead: ... bytes(("X%x,4:" % addr).encode('ascii') + bytearray([0x2, 0x2, 0x2, 0x2])). ... --- gdb/testsuite/gdb.python/py-send-packet.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.python/py-send-packet.py b/gdb/testsuite/gdb.python/py-send-packet.py index 4966688a922..f58deed1019 100644 --- a/gdb/testsuite/gdb.python/py-send-packet.py +++ b/gdb/testsuite/gdb.python/py-send-packet.py @@ -122,6 +122,15 @@ def check_global_var(expected_val): if val != expected_val: raise gdb.GdbError("global_var is 0x%x, expected 0x%x" % (val, expected_val)) +# Return a bytes object representing an 'X' packet with +# address ADDR and bytes L. +def bytes_xpacket (addr, l): + # Implement b"X%x,4:\xff\xff\xff\xff" % addr in a way that works + # across python versions. + res = ("X%x,4:" % addr).encode('ascii') + bytearray(l) + # Force it to type bytes. + res = bytes(res) + return res # Set the 'X' packet to the remote target to set a global variable. # Checks that we can send byte values. @@ -133,7 +142,7 @@ def run_set_global_var_test(): res = conn.send_packet("X%x,4:\x01\x01\x01\x01" % addr) assert isinstance(res, bytes) check_global_var(0x01010101) - res = conn.send_packet(b"X%x,4:\x02\x02\x02\x02" % addr) + res = conn.send_packet(bytes_xpacket(addr, [0x2, 0x2, 0x2, 0x2])) assert isinstance(res, bytes) check_global_var(0x02020202) if sys.version_info[0] > 2: @@ -149,7 +158,7 @@ def run_set_global_var_test(): assert saw_error check_global_var(0x02020202) # Now we pass a bytes object, which will work. - res = conn.send_packet(b"X%x,4:\xff\xff\xff\xff" % addr) + res = conn.send_packet(bytes_xpacket(addr, [0xff, 0xff, 0xff, 0xff])) check_global_var(0xFFFFFFFF) else: # On Python 2 we need to force the creation of a Unicode
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor