From 249c391a81c2480279bcbfb3823c56fa952b7ccf Mon Sep 17 00:00:00 2001 From: Qijia Liu Date: Sun, 12 Jan 2025 19:41:54 -0500 Subject: [PATCH] Use str.isascii --- tools/building.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/tools/building.py b/tools/building.py index 3d764fe82d33a..231b810ce4c60 100644 --- a/tools/building.py +++ b/tools/building.py @@ -476,17 +476,6 @@ def check_closure_compiler(cmd, args, env, allowed_to_fail): return True -# Remove this once we require python3.7 and can use std.isascii. -# See: https://docs.python.org/3/library/stdtypes.html#str.isascii -def isascii(s): - try: - s.encode('ascii') - except UnicodeEncodeError: - return False - else: - return True - - def get_closure_compiler_and_env(user_args): env = shared.env_with_node_in_path() closure_cmd = get_closure_compiler() @@ -623,7 +612,7 @@ def run_closure_cmd(cmd, filename, env): tempfiles = shared.get_temp_files() def move_to_safe_7bit_ascii_filename(filename): - if isascii(filename): + if filename.isascii(): return os.path.abspath(filename) safe_filename = tempfiles.get('.js').name # Safe 7-bit filename shutil.copyfile(filename, safe_filename)