[Lldb-commits] [PATCH] D114156: [lldb/test] Add ability to terminate connection from a gdb-client handler

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 18 09:48:10 PST 2021


labath added inline comments.


================
Comment at: lldb/packages/Python/lldbsuite/test/gdbclientutils.py:89
     packetLog = None
+    RESPONSE_DISCONNECT = object()
 
----------------
mgorny wrote:
> How about making it a class instead? It should make debugging easier, if it ever comes to that.
> 
> ```
> In [6]: RESPONSE_DISCONNECT = object()
> 
> In [7]: RESPONSE_DISCONNECT
> Out[7]: <object at 0x7f406dd328e0>
> 
> In [8]: class RESPONSE_DISCONNECT: pass
> 
> In [9]: RESPONSE_DISCONNECT
> Out[9]: __main__.RESPONSE_DISCONNECT
> ```
I wouldn't call myself an expert on idiomatic python, but I was under the impression this is how one is expected to do these things <https://python-patterns.guide/python/sentinel-object/> (?)


================
Comment at: lldb/packages/Python/lldbsuite/test/gdbclientutils.py:611
+            if part is MockGDBServerResponder.RESPONSE_DISCONNECT:
+                raise self.TerminateConnectionException
+            self._sendPacket(part)
----------------
mgorny wrote:
> It feels weird that you're raising class rather than an object.
It looks like the class gets automatically instantiated (https://docs.python.org/3/tutorial/errors.html#raising-exceptions), though now that I think about it, I am actually surprised that it does :P


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114156/new/

https://reviews.llvm.org/D114156



More information about the lldb-commits mailing list