From 82a0efcb31b00178b3c7321ac3f6eb3ac73c6ce4 Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Thu, 30 Oct 2025 15:56:10 +0000 Subject: [PATCH] mitogen: Allow line comments in first stage, strip them. --- mitogen/parent.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mitogen/parent.py b/mitogen/parent.py index 6e30b1c6..71641d36 100644 --- a/mitogen/parent.py +++ b/mitogen/parent.py @@ -1463,8 +1463,9 @@ class Connection(object): return [self.options.python_path] def get_boot_command(self): - source = inspect.getsource(self._first_stage) - source = textwrap.dedent('\n'.join(source.strip().split('\n')[2:])) + lines = inspect.getsourcelines(self._first_stage)[0][2:] + # Remove line comments, leading indentation, trailing newline + source = textwrap.dedent(''.join(s for s in lines if '#' not in s))[:-1] source = source.replace(' ', ' ') compressor = zlib.compressobj( zlib.Z_BEST_COMPRESSION, zlib.DEFLATED, -zlib.MAX_WBITS,