mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
7214b034eb
5d62dcf9cfb5c0b2511c10667ed47ec3b3610d72 lint: Make sure we read the command line inputs using utf-8 decoding in python (Chun Kuan Lee) Pull request description: Make sure we read the command line inputs using utf-8 decoding in python occurred from travis cron job: contrib/verify-commits/verify-commits.py should run with utf-8, otherwise it would raise UnicodeDecodeError `UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 744: ordinal not in range(128)` Tree-SHA512: 90e4ad57fdbbbecb0a21fc2d2b03a04f5ef125e54124719ef36e5a85326930b732b47534757a7c3a8730096f3947b009ec898191928b5c2d38f9f4b3e37db48d # Conflicts: # contrib/devtools/optimize-pngs.py
29 lines
1.1 KiB
Bash
Executable File
29 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Copyright (c) 2018 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
#
|
|
# Make sure we explicitly open all text files using UTF-8 (or ASCII) encoding to
|
|
# avoid potential issues on the BSDs where the locale is not always set.
|
|
|
|
export LC_ALL=C
|
|
EXIT_CODE=0
|
|
OUTPUT=$(git grep " open(" -- "*.py" | grep -vE "encoding=.(ascii|utf8|utf-8)." | grep -vE "open\([^,]*, ['\"][^'\"]*b[^'\"]*['\"]")
|
|
if [[ ${OUTPUT} != "" ]]; then
|
|
echo "Python's open(...) seems to be used to open text files without explicitly"
|
|
echo "specifying encoding=\"utf8\":"
|
|
echo
|
|
echo "${OUTPUT}"
|
|
EXIT_CODE=1
|
|
fi
|
|
OUTPUT=$(git grep "check_output(" -- "*.py" | grep "universal_newlines=True" | grep -vE "encoding=.(ascii|utf8|utf-8).")
|
|
if [[ ${OUTPUT} != "" ]]; then
|
|
echo "Python's check_output(...) seems to be used to get program outputs without explicitly"
|
|
echo "specifying encoding=\"utf8\":"
|
|
echo
|
|
echo "${OUTPUT}"
|
|
EXIT_CODE=1
|
|
fi
|
|
exit ${EXIT_CODE}
|