Skip to content

Commit ba06aca

Browse files
authored
Remove unused argument from create_repsonse_file. NFC (#24110)
This was originally added back in #15426 but never used.
1 parent 858d13b commit ba06aca

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

tools/response_file.py

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,12 @@
1313
DEBUG = int(os.environ.get('EMCC_DEBUG', '0'))
1414

1515

16-
def create_response_file(args, directory, suffix='.rsp.utf-8'):
16+
def create_response_file(args, directory):
1717
"""Routes the given cmdline param list in args into a new response file and
1818
returns the filename to it.
19-
20-
By default the returned filename has a suffix '.rsp.utf-8'. Pass a suffix parameter to override.
2119
"""
2220

23-
assert suffix.startswith('.')
24-
25-
response_fd, response_filename = tempfile.mkstemp(prefix='emscripten_', suffix=suffix, dir=directory, text=True)
21+
response_fd, response_filename = tempfile.mkstemp(prefix='emscripten_', suffix='.rsp.utf-8', dir=directory, text=True)
2622

2723
# Backslashes and other special chars need to be escaped in the response file.
2824
escape_chars = ['\\', '\"']
@@ -36,26 +32,19 @@ def escape(arg):
3632
return arg
3733

3834
args = [escape(a) for a in args]
39-
contents = ""
35+
contents = ''
4036

4137
# Arguments containing spaces need to be quoted.
4238
for arg in args:
4339
if ' ' in arg:
4440
arg = '"%s"' % arg
4541
contents += arg + '\n'
4642

47-
# Decide the encoding of the generated file based on the requested file suffix
48-
if suffix.count('.') == 2:
49-
# Use the encoding specified in the suffix of the response file
50-
encoding = suffix.split('.')[2]
51-
else:
52-
encoding = 'utf-8'
53-
54-
with os.fdopen(response_fd, 'w', encoding=encoding) as f:
43+
with os.fdopen(response_fd, 'w', encoding='utf-8') as f:
5544
f.write(contents)
5645

5746
if DEBUG:
58-
logging.warning('Creating response file ' + response_filename + ' with following contents: ' + contents)
47+
logging.warning(f'Creating response file {response_filename} with following contents: {contents}')
5948

6049
# Register the created .rsp file to be automatically cleaned up once this
6150
# process finishes, so that caller does not have to remember to do it.
@@ -98,15 +87,15 @@ def read_response_file(response_filename):
9887
args = f.read()
9988
except (ValueError, LookupError): # UnicodeDecodeError is a subclass of ValueError, and Python raises either a ValueError or a UnicodeDecodeError on decode errors. LookupError is raised if guessed encoding is not an encoding.
10089
if DEBUG:
101-
logging.warning(f'Failed to parse response file {response_filename} with guessed encoding "{guessed_encoding}". Trying default system encoding...')
90+
logging.warning(f'failed to parse response file {response_filename} with guessed encoding "{guessed_encoding}". Trying default system encoding...')
10291
# If that fails, try with the Python default locale.getpreferredencoding()
10392
with open(response_filename) as f:
10493
args = f.read()
10594

10695
args = shlex.split(args)
10796

10897
if DEBUG:
109-
logging.warning('Read response file ' + response_filename + ': ' + str(args))
98+
logging.warning(f'read response file {response_filename}: {args}')
11099

111100
return args
112101

0 commit comments

Comments
 (0)