Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use str.isascii #23378

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are proposing we drop support for python3.6 can you open a bug for that where we can discuss the costs/benefits?

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
Loading