This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Make socket_packet_pump.py work in Python3
ClosedPublic

Authored by teemperor on Jul 17 2020, 4:25 AM.

Details

Summary

The string_escape encoding used here was removed in Python 3 which makes the test crash during tearDown:

  File "/Users/teemperor/3llvm/llvm-project/lldb/third_party/Python/module/unittest2/unittest2/case.py", line 386, in run
    self.tearDown()
  File "/Users/teemperor/3llvm/llvm-project/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py", line 124, in tearDown
    self._pump_queues.verify_queues_empty()
  File "/Users/teemperor/3llvm/llvm-project/lldb/packages/Python/lldbsuite/test/tools/lldb-server/socket_packet_pump.py", line 55, in verify_queues_empty
    _dump_queue(self.packet_queue())
  File "/Users/teemperor/3llvm/llvm-project/lldb/packages/Python/lldbsuite/test/tools/lldb-server/socket_packet_pump.py", line 28, in _dump_queue
    print(codecs.encode(the_queue.get(True), "string_escape"))
LookupError: unknown encoding: string_escape

Just replace it with repr which should work in both Python versions.

Diff Detail

Event Timeline

teemperor created this revision.Jul 17 2020, 4:25 AM

How about print(repr(foo))? That should do something reasonable everywhere...

teemperor updated this revision to Diff 278723.Jul 17 2020, 4:35 AM
  • Moved to repr.
teemperor edited the summary of this revision. (Show Details)Jul 17 2020, 4:37 AM

Yeah repr also does the trick of escaping the null bytes.

labath accepted this revision.Jul 17 2020, 4:40 AM
This revision is now accepted and ready to land.Jul 17 2020, 4:40 AM
JDevlieghere accepted this revision.Jul 17 2020, 8:21 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 23 2020, 9:37 AM