Skip to content

Commit efa5725

Browse files
DavidSpickettakadutta
authored andcommitted
[lldb][test] Replace seven.join_for_shell with shlex.join (llvm#163191)
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
1 parent 9594a7e commit efa5725

File tree

4 files changed

+5
-10
lines changed

4 files changed

+5
-10
lines changed

lldb/packages/Python/lldbsuite/support/seven.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import binascii
2-
import shlex
32
import subprocess
43

54

@@ -38,8 +37,3 @@ def unhexlify(hexstr):
3837
def hexlify(data):
3938
"""Hex-encode string data. The result if always a string."""
4039
return bitcast_to_string(binascii.hexlify(bitcast_to_bytes(data)))
41-
42-
43-
# TODO: Replace this with `shlex.join` when minimum Python version is >= 3.8
44-
def join_for_shell(split_command):
45-
return " ".join([shlex.quote(part) for part in split_command])

lldb/packages/Python/lldbsuite/test/lldbtest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import os.path
3737
import re
3838
import shutil
39+
import shlex
3940
import signal
4041
from subprocess import *
4142
import sys
@@ -56,7 +57,6 @@
5657
from . import test_categories
5758
from lldbsuite.support import encoded_file
5859
from lldbsuite.support import funcutils
59-
from lldbsuite.support import seven
6060
from lldbsuite.test_event import build_exception
6161

6262
# See also dotest.parseOptionsAndInitTestdirs(), where the environment variables
@@ -1508,7 +1508,7 @@ def build(
15081508
self.runBuildCommand(command)
15091509

15101510
def runBuildCommand(self, command):
1511-
self.trace(seven.join_for_shell(command))
1511+
self.trace(shlex.join(command))
15121512
try:
15131513
output = check_output(command, stderr=STDOUT, errors="replace")
15141514
except CalledProcessError as cpe:

lldb/packages/Python/lldbsuite/test_event/build_exception.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from lldbsuite.support import seven
1+
import shlex
22

33

44
class BuildError(Exception):
55
def __init__(self, called_process_error):
66
super(BuildError, self).__init__("Error when building test subject")
7-
self.command = seven.join_for_shell(called_process_error.cmd)
7+
self.command = shlex.join(called_process_error.cmd)
88
self.build_error = called_process_error.output
99

1010
def __str__(self):

lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from lldbsuite.test.decorators import *
44
from lldbsuite.test.lldbtest import *
5+
from lldbsuite.support import seven
56

67
from fork_testbase import GdbRemoteForkTestBase
78

0 commit comments

Comments
 (0)