Skip to content

Commit 0782508

Browse files
author
MarcoFalke
committed
Merge #12972: Add python3 script shebang lint
2bff472 [contrib] convert test-security-check to python3 (John Newbery) 958bf40 add lint tool to check python3 shebang (practicalswift) Pull request description: base58.py can executed by python3 Tree-SHA512: 30511204feefd4ccd5b4bf698fb88e516633e692dc95d31fe957b1c0c4879de25906355b28a5a0522171887315c8464a611e601ff00540db172d5bd463ee13d9
2 parents 4366f61 + 2bff472 commit 0782508

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
# Shebang must use python3 (not python or python2)
3+
EXIT_CODE=0
4+
for PYTHON_FILE in $(git ls-files -- "*.py"); do
5+
if [[ $(head -c 2 "${PYTHON_FILE}") == "#!" &&
6+
$(head -n 1 "${PYTHON_FILE}") != "#!/usr/bin/env python3" ]]; then
7+
echo "Missing shebang \"#!/usr/bin/env python3\" in ${PYTHON_FILE} (do not use python or python2)"
8+
EXIT_CODE=1
9+
fi
10+
done
11+
exit ${EXIT_CODE}

contrib/devtools/test-security-check.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
#!/usr/bin/env python2
1+
#!/usr/bin/env python3
22
# Copyright (c) 2015-2017 The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
'''
66
Test script for security-check.py
77
'''
8-
from __future__ import division,print_function
98
import subprocess
109
import unittest
1110

@@ -22,7 +21,7 @@ def write_testcode(filename):
2221

2322
def call_security_check(cc, source, executable, options):
2423
subprocess.check_call([cc,source,'-o',executable] + options)
25-
p = subprocess.Popen(['./security-check.py',executable], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
24+
p = subprocess.Popen(['./security-check.py',executable], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, universal_newlines=True)
2625
(stdout, stderr) = p.communicate()
2726
return (p.returncode, stdout.rstrip())
2827

0 commit comments

Comments
 (0)