mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
d1200755f1
c8176b3cc7556d7bcec39a55ae4d6ba16453baaa Add linter: Make sure we explicitly open all text files using UTF-8 or ASCII encoding in Python (practicalswift) 634bd970013eca90f4b4c1f9044eec8c97ba62c2 Explicitly specify encoding when opening text files in Python code (practicalswift) Pull request description: Add linter: Make sure we explicitly open all text files using UTF-8 encoding in Python. As requested by @laanwj in #13440. Tree-SHA512: 1651c00fe220ceb273324abd6703aee504029b96c7ef0e3029145901762c733c9b9d24927da281394fd4681a5bff774336c04eed01fafea997bb32192c334c06 Signed-off-by: pasta <pasta@dashboost.org> # Conflicts: # contrib/devtools/circular-dependencies.py # contrib/linearize/linearize-data.py # contrib/linearize/linearize-hashes.py # contrib/seeds/generate-seeds.py # contrib/verify-commits/verify-commits.py # test/functional/multiwallet.py # test/functional/notifications.py # test/functional/test_runner.py # test/util/rpcauth-test.py
20 lines
726 B
Bash
Executable File
20 lines
726 B
Bash
Executable File
#!/bin/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.
|
|
|
|
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
|
|
exit ${EXIT_CODE}
|