From d70d401c7291a2f24e3499bb91b50a32db74779a Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Thu, 13 Dec 2018 13:12:41 +0100 Subject: [PATCH] Merge #14884: Travis: enforce Python 3.4 support through linter 31926ee8cfc73501524dfa0fef2ccbaa786d6a00 [test] functional framework: add CScript hex() for Python 3.4 (Sjors Provoost) 74ce32683199b987e45eb16f0320ae392ff10edc [test] Travis: enforce Python 3.4 support in functional tests (Sjors Provoost) Pull request description: The minimum supported version of Python is 3.4 according to [dependencies.md](https://github.com/bitcoin/bitcoin/blob/master/doc/dependencies.md). This PR makes the Travis linter use this version in order to catch accidental use of modern syntax. Tree-SHA512: 71b2c102be72b135a8ba049378d66875760f20a04a657102a399240c5c2b2ddbdfa7d5ab4c0c0242ecc3259e0ee8eb2273f331bc5eb824f4ae4c3cc58aea37ac --- .python-version | 1 + .travis.yml | 2 +- test/functional/test_framework/script.py | 4 ++++ test/lint/check-doc.py | 8 ++++++-- 4 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 .python-version diff --git a/.python-version b/.python-version new file mode 100644 index 0000000000..7bcbb3808b --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.4.9 diff --git a/.travis.yml b/.travis.yml index 0361562aa0..87f54cc24a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -206,7 +206,7 @@ after_success: sudo: false cache: false language: python - python: '3.6' + python: '3.4' # Oldest supported version according to doc/dependencies.md install: - set -o errexit; source .travis/lint_04_install.sh before_script: diff --git a/test/functional/test_framework/script.py b/test/functional/test_framework/script.py index 4dfb787323..8395e50e78 100644 --- a/test/functional/test_framework/script.py +++ b/test/functional/test_framework/script.py @@ -430,6 +430,10 @@ class CScript(bytes): # join makes no sense for a CScript() raise NotImplementedError + # Python 3.4 compatibility + def hex(self): + return hexlify(self).decode('ascii') + def __new__(cls, value=b''): if isinstance(value, bytes) or isinstance(value, bytearray): return super(CScript, cls).__new__(cls, value) diff --git a/test/lint/check-doc.py b/test/lint/check-doc.py index a8f29feda4..7e4b62a6cd 100755 --- a/test/lint/check-doc.py +++ b/test/lint/check-doc.py @@ -26,8 +26,12 @@ SET_DOC_OPTIONAL = set(['-rpcssl', '-benchmark', '-h', '-help', '-socks', '-tor' def main(): - used = check_output(CMD_GREP_ARGS, shell=True, universal_newlines=True, encoding='utf8') - docd = check_output(CMD_GREP_DOCS, shell=True, universal_newlines=True, encoding='utf8') + if sys.version_info >= (3, 6): + used = check_output(CMD_GREP_ARGS, shell=True, universal_newlines=True, encoding='utf8') + docd = check_output(CMD_GREP_DOCS, shell=True, universal_newlines=True, encoding='utf8') + else: + used = check_output(CMD_GREP_ARGS, shell=True, universal_newlines=True) # encoding='utf8' + docd = check_output(CMD_GREP_DOCS, shell=True, universal_newlines=True) # encoding='utf8' args_used = set(re.findall(re.compile(REGEX_ARG), used)) args_docd = set(re.findall(re.compile(REGEX_DOC), docd)).union(SET_DOC_OPTIONAL)