From 6e20532654766001cba1cc7c5171e357343bd016 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 15 Apr 2025 11:42:10 -0700 Subject: [PATCH] Remove unused argument from create_repsonse_file. NFC This was originally added back in #15426 but never used. --- tools/response_file.py | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/tools/response_file.py b/tools/response_file.py index fbe20a790aba2..64c5c0444304e 100644 --- a/tools/response_file.py +++ b/tools/response_file.py @@ -13,16 +13,12 @@ DEBUG = int(os.environ.get('EMCC_DEBUG', '0')) -def create_response_file(args, directory, suffix='.rsp.utf-8'): +def create_response_file(args, directory): """Routes the given cmdline param list in args into a new response file and returns the filename to it. - - By default the returned filename has a suffix '.rsp.utf-8'. Pass a suffix parameter to override. """ - assert suffix.startswith('.') - - response_fd, response_filename = tempfile.mkstemp(prefix='emscripten_', suffix=suffix, dir=directory, text=True) + response_fd, response_filename = tempfile.mkstemp(prefix='emscripten_', suffix='.rsp.utf-8', dir=directory, text=True) # Backslashes and other special chars need to be escaped in the response file. escape_chars = ['\\', '\"'] @@ -36,7 +32,7 @@ def escape(arg): return arg args = [escape(a) for a in args] - contents = "" + contents = '' # Arguments containing spaces need to be quoted. for arg in args: @@ -44,18 +40,11 @@ def escape(arg): arg = '"%s"' % arg contents += arg + '\n' - # Decide the encoding of the generated file based on the requested file suffix - if suffix.count('.') == 2: - # Use the encoding specified in the suffix of the response file - encoding = suffix.split('.')[2] - else: - encoding = 'utf-8' - - with os.fdopen(response_fd, 'w', encoding=encoding) as f: + with os.fdopen(response_fd, 'w', encoding='utf-8') as f: f.write(contents) if DEBUG: - logging.warning('Creating response file ' + response_filename + ' with following contents: ' + contents) + logging.warning(f'Creating response file {response_filename} with following contents: {contents}') # Register the created .rsp file to be automatically cleaned up once this # process finishes, so that caller does not have to remember to do it. @@ -98,7 +87,7 @@ def read_response_file(response_filename): args = f.read() 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. if DEBUG: - logging.warning(f'Failed to parse response file {response_filename} with guessed encoding "{guessed_encoding}". Trying default system encoding...') + logging.warning(f'failed to parse response file {response_filename} with guessed encoding "{guessed_encoding}". Trying default system encoding...') # If that fails, try with the Python default locale.getpreferredencoding() with open(response_filename) as f: args = f.read() @@ -106,7 +95,7 @@ def read_response_file(response_filename): args = shlex.split(args) if DEBUG: - logging.warning('Read response file ' + response_filename + ': ' + str(args)) + logging.warning(f'read response file {response_filename}: {args}') return args