From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id A3BD71382C5 for ; Fri, 15 Jan 2021 17:06:01 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D1FEEE087C; Fri, 15 Jan 2021 17:06:00 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A6CB8E087C for ; Fri, 15 Jan 2021 17:06:00 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 73C71340D2B for ; Fri, 15 Jan 2021 17:05:59 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 2F173498 for ; Fri, 15 Jan 2021 17:05:58 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1610730353.10da6fd3ccd3ba547cb855371b670db909cb165c.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/python-utils-r1.eclass eclass/tests/python-utils-r1.sh X-VCS-Directories: eclass/tests/ eclass/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 10da6fd3ccd3ba547cb855371b670db909cb165c X-VCS-Branch: master Date: Fri, 15 Jan 2021 17:05:58 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 237bd863-120e-4972-9959-62a84054df5f X-Archives-Hash: 819081330b560e72d9e59c03757deaeb commit: 10da6fd3ccd3ba547cb855371b670db909cb165c Author: Michał Górny gentoo org> AuthorDate: Thu Dec 31 11:18:04 2020 +0000 Commit: Michał Górny gentoo org> CommitDate: Fri Jan 15 17:05:53 2021 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=10da6fd3 python-utils-r1.eclass: Inline _python_impl_supported() The _python_impl_supported() function is not used anymore in its original function. It is called only once, in order to die on incorrect targets in PYTHON_COMPAT. Let's inline the corresponding logic in _python_set_impls() and remove the function. While at it, add an extra check for outdated patterns. This also renders the relevant tests obsolete. Signed-off-by: Michał Górny gentoo.org> eclass/python-utils-r1.eclass | 56 +++++++++++++++-------------------------- eclass/tests/python-utils-r1.sh | 18 ------------- 2 files changed, 20 insertions(+), 54 deletions(-) diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index 9c8b6a14d2a..2aa953213b6 100644 --- a/eclass/python-utils-r1.eclass +++ b/eclass/python-utils-r1.eclass @@ -69,38 +69,6 @@ readonly _PYTHON_HISTORICAL_IMPLS # which can involve revisions of this eclass that support a different # set of Python implementations. -# @FUNCTION: _python_impl_supported -# @USAGE: -# @INTERNAL -# @DESCRIPTION: -# Check whether the implementation (PYTHON_COMPAT-form) -# is still supported. -# -# Returns 0 if the implementation is valid and supported. If it is -# unsupported, returns 1 -- and the caller should ignore the entry. -# If it is invalid, dies with an appopriate error messages. -_python_impl_supported() { - debug-print-function ${FUNCNAME} "${@}" - - [[ ${#} -eq 1 ]] || die "${FUNCNAME}: takes exactly 1 argument (impl)." - - local impl=${1} - - # keep in sync with _PYTHON_ALL_IMPLS! - # (not using that list because inline patterns shall be faster) - case "${impl}" in - python2_7|python3_[6789]|pypy3) - return 0 - ;; - jython2_7|pypy|pypy1_[89]|pypy2_0|python2_[56]|python3_[12345]) - return 1 - ;; - *) - [[ ${PYTHON_COMPAT_NO_STRICT} ]] && return 1 - die "Invalid implementation in PYTHON_COMPAT: ${impl}" - esac -} - # @FUNCTION: _python_verify_patterns # @USAGE: ... # @INTERNAL @@ -149,10 +117,26 @@ _python_set_impls() { if [[ $(declare -p PYTHON_COMPAT) != "declare -a"* ]]; then die 'PYTHON_COMPAT must be an array.' fi - for i in "${PYTHON_COMPAT[@]}"; do - # trigger validity checks - _python_impl_supported "${i}" - done + if [[ ! ${PYTHON_COMPAT_NO_STRICT} ]]; then + for i in "${PYTHON_COMPAT[@]}"; do + # check for incorrect implementations + # we're using pattern matching as an optimization + # please keep them in sync with _PYTHON_ALL_IMPLS + # and _PYTHON_HISTORICAL_IMPLS + case ${i} in + jython2_7|pypy|pypy1_[89]|pypy2_0|pypy3|python2_[5-7]|python3_[1-9]) + ;; + *) + if has "${i}" "${_PYTHON_ALL_IMPLS[@]}" \ + "${_PYTHON_HISTORICAL_IMPLS[@]}" + then + die "Mis-synced patterns in _python_set_impls: missing ${i}" + else + die "Invalid implementation in PYTHON_COMPAT: ${i}" + fi + esac + done + fi local supp=() unsupp=() diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh index 86b87ec173d..eb8223ec6ac 100755 --- a/eclass/tests/python-utils-r1.sh +++ b/eclass/tests/python-utils-r1.sh @@ -183,24 +183,6 @@ test_fix_shebang '#!/usr/bin/foo' python2.7 FAIL # regression test for bug #522080 test_fix_shebang '#!/usr/bin/python ' python2.7 '#!/usr/bin/python2.7 ' -# make sure we don't break pattern matching -test_is "_python_impl_supported python2_5" 1 -test_is "_python_impl_supported python2_6" 1 -test_is "_python_impl_supported python2_7" 0 -test_is "_python_impl_supported python3_1" 1 -test_is "_python_impl_supported python3_2" 1 -test_is "_python_impl_supported python3_3" 1 -test_is "_python_impl_supported python3_4" 1 -test_is "_python_impl_supported python3_5" 1 -test_is "_python_impl_supported python3_6" 0 -test_is "_python_impl_supported python3_7" 0 -test_is "_python_impl_supported python3_8" 0 -test_is "_python_impl_supported pypy1_8" 1 -test_is "_python_impl_supported pypy1_9" 1 -test_is "_python_impl_supported pypy2_0" 1 -test_is "_python_impl_supported pypy" 1 -test_is "_python_impl_supported pypy3" 0 - # check _python_impl_matches behavior test_is "_python_impl_matches python2_7 -2" 0 test_is "_python_impl_matches python3_6 -2" 1