Skip to content

Commit

Permalink
Use str.isascii
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj committed Jan 13, 2025
1 parent aca6884 commit 249c391
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions tools/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 249c391

Please sign in to comment.