Fix presubmit format check and always use UTF-8 in Python on Windows.

This commit is contained in:
Aleksey Khoroshilov
2023-12-21 14:00:44 +07:00
parent 3cad6665b0
commit 6c86a03f92
2 changed files with 13 additions and 0 deletions
+6
View File
@@ -79,6 +79,12 @@ def CheckPatchFormatted(input_api, output_api):
# Run git cl format and get return code.
git_cl_format_code, _ = git_cl.RunGitWithCode(git_cl_format_cmd)
if git_cl_format_code not in (0, 2):
return [
output_api.PresubmitError(
f'Presubmit format check has failed, return code: {git_cl_format_code}'
)
]
is_format_required = git_cl_format_code == 2
+7
View File
@@ -1196,6 +1196,13 @@ Object.defineProperty(Config.prototype, 'defaultOptions', {
env = this.addPythonPathToEnv(env, path.join(this.srcDir, ...p))
})
env.PYTHONUNBUFFERED = '1'
if (process.platform === 'win32') {
// UTF-8 is default on Linux/Mac, but on Windows CP1252 is used in most
// cases. This var makes Python use UTF-8 if encoding is not set
// explicitly in calls such as `open()`.
// https://peps.python.org/pep-0540/
env.PYTHONUTF8 = '1'
}
env.TARGET_ARCH = this.gypTargetArch // for brave scripts
env.RUSTUP_HOME = path.join(this.srcDir, 'third_party', 'rust-toolchain')
// Fix `gclient runhooks` - broken since depot_tools a7b20b34f85432b5958963b75edcedfef9cf01fd