Skip to content

Conversation

@DavidSpickett
Copy link
Collaborator

shlex.join is available in Python 3.8, which is the LLVM Project's minimum version.

https://docs.python.org/3/library/shlex.html#shlex.join

shlex.join is available in Python 3.8, which is the LLVM
Project's minimum version.
@DavidSpickett DavidSpickett added the skip-precommit-approval PR for CI feedback, not intended for review label Oct 13, 2025
@llvmbot llvmbot added the lldb label Oct 13, 2025
@llvmbot
Copy link
Member

llvmbot commented Oct 13, 2025

@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)

Changes

shlex.join is available in Python 3.8, which is the LLVM Project's minimum version.

https://docs.python.org/3/library/shlex.html#shlex.join


Full diff: https://github.com/llvm/llvm-project/pull/163191.diff

3 Files Affected:

  • (modified) lldb/packages/Python/lldbsuite/support/seven.py (-6)
  • (modified) lldb/packages/Python/lldbsuite/test/lldbtest.py (+2-2)
  • (modified) lldb/packages/Python/lldbsuite/test_event/build_exception.py (+2-2)
diff --git a/lldb/packages/Python/lldbsuite/support/seven.py b/lldb/packages/Python/lldbsuite/support/seven.py
index 1b96658b68eda..8e621ba1ee91b 100644
--- a/lldb/packages/Python/lldbsuite/support/seven.py
+++ b/lldb/packages/Python/lldbsuite/support/seven.py
@@ -1,5 +1,4 @@
 import binascii
-import shlex
 import subprocess
 
 
@@ -38,8 +37,3 @@ def unhexlify(hexstr):
 def hexlify(data):
     """Hex-encode string data. The result if always a string."""
     return bitcast_to_string(binascii.hexlify(bitcast_to_bytes(data)))
-
-
-# TODO: Replace this with `shlex.join` when minimum Python version is >= 3.8
-def join_for_shell(split_command):
-    return " ".join([shlex.quote(part) for part in split_command])
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 8074922723440..b92de941c4124 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -36,6 +36,7 @@
 import os.path
 import re
 import shutil
+import shlex
 import signal
 from subprocess import *
 import sys
@@ -56,7 +57,6 @@
 from . import test_categories
 from lldbsuite.support import encoded_file
 from lldbsuite.support import funcutils
-from lldbsuite.support import seven
 from lldbsuite.test_event import build_exception
 
 # See also dotest.parseOptionsAndInitTestdirs(), where the environment variables
@@ -1508,7 +1508,7 @@ def build(
         self.runBuildCommand(command)
 
     def runBuildCommand(self, command):
-        self.trace(seven.join_for_shell(command))
+        self.trace(shlex.join(command))
         try:
             output = check_output(command, stderr=STDOUT, errors="replace")
         except CalledProcessError as cpe:
diff --git a/lldb/packages/Python/lldbsuite/test_event/build_exception.py b/lldb/packages/Python/lldbsuite/test_event/build_exception.py
index 931c15da0d5ef..c3ae2cdfca06d 100644
--- a/lldb/packages/Python/lldbsuite/test_event/build_exception.py
+++ b/lldb/packages/Python/lldbsuite/test_event/build_exception.py
@@ -1,10 +1,10 @@
-from lldbsuite.support import seven
+import shlex
 
 
 class BuildError(Exception):
     def __init__(self, called_process_error):
         super(BuildError, self).__init__("Error when building test subject")
-        self.command = seven.join_for_shell(called_process_error.cmd)
+        self.command = shlex.join(called_process_error.cmd)
         self.build_error = called_process_error.output
 
     def __str__(self):

@DavidSpickett DavidSpickett enabled auto-merge (squash) October 13, 2025 12:40
@DavidSpickett DavidSpickett merged commit 0dd51f9 into llvm:main Oct 13, 2025
7 of 9 checks passed
akadutta pushed a commit to akadutta/llvm-project that referenced this pull request Oct 14, 2025
shlex.join is available in Python 3.8, which is the LLVM Project's
minimum version.

https://docs.python.org/3/library/shlex.html#shlex.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lldb skip-precommit-approval PR for CI feedback, not intended for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants