@@ -264,7 +264,7 @@ def _create_script(self, script=None):
264
264
def foo():
265
265
x = 42
266
266
return bar()
267
-
267
+
268
268
def bar():
269
269
return 42
270
270
@@ -311,13 +311,13 @@ def _connect_and_get_client_file(self):
311
311
stderr = subprocess .PIPE ,
312
312
text = True
313
313
)
314
-
314
+
315
315
# Accept the connection from the subprocess
316
316
client_sock , _ = self .server_sock .accept ()
317
317
client_file = client_sock .makefile ('rwb' )
318
318
self .addCleanup (client_file .close )
319
319
self .addCleanup (client_sock .close )
320
-
320
+
321
321
return process , client_file
322
322
323
323
def _read_until_prompt (self , client_file ):
@@ -337,7 +337,7 @@ def _send_command(self, client_file, command):
337
337
"""Helper to send a command to the debugger."""
338
338
client_file .write (json .dumps ({"reply" : command }).encode () + b"\n " )
339
339
client_file .flush ()
340
-
340
+
341
341
def _send_interrupt (self , pid ):
342
342
"""Helper to send an interrupt signal to the debugger."""
343
343
# with tempfile.NamedTemporaryFile("w", delete_on_close=False) as interrupt_script:
@@ -349,7 +349,10 @@ def _send_interrupt(self, pid):
349
349
'if inst := pdb.Pdb._last_pdb_instance:\n '
350
350
' inst.set_trace(sys._getframe(1))\n '
351
351
)
352
- sys .remote_exec (pid , interrupt_script )
352
+ try :
353
+ sys .remote_exec (pid , interrupt_script )
354
+ except PermissionError :
355
+ self .skipTest ("Insufficient permissions to execute code in remote process" )
353
356
self .addCleanup (unlink , interrupt_script )
354
357
355
358
def test_connect_and_basic_commands (self ):
@@ -380,9 +383,9 @@ def test_connect_and_basic_commands(self):
380
383
381
384
# Check for response - we should get some stack frames
382
385
messages = self ._read_until_prompt (client_file )
383
-
386
+
384
387
# Extract text messages containing stack info
385
- text_msg = [msg ['message' ] for msg in messages
388
+ text_msg = [msg ['message' ] for msg in messages
386
389
if 'message' in msg and 'connect_to_debugger' in msg ['message' ]]
387
390
got_stack_info = bool (text_msg )
388
391
@@ -423,7 +426,7 @@ def test_breakpoints(self):
423
426
# Continue execution until breakpoint
424
427
self ._send_command (client_file , "c" )
425
428
messages = self ._read_until_prompt (client_file )
426
-
429
+
427
430
# Verify we hit the breakpoint
428
431
hit_msg = next (msg ['message' ] for msg in messages if 'message' in msg )
429
432
self .assertIn ("bar()" , hit_msg )
0 commit comments