Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Wed, 23 Jun 2021 21:44:36
Message-Id: 1624484646.b3071fedb9d0d907173de2ce66478bd6d9770f93.mgorny@gentoo
1 commit: b3071fedb9d0d907173de2ce66478bd6d9770f93
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sun Jun 20 07:35:10 2021 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Wed Jun 23 21:44:06 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b3071fed
7
8 python-utils-r1.eclass: Eliminate local python_is_python3 uses
9
10 Do not use python_is_python3 in eclass functions to ease banning it.
11 Except for wrapper setup that is still used in py2 any-r1 context,
12 we can unconditionally assume Python 3 everywhere.
13
14 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
15
16 eclass/python-utils-r1.eclass | 16 ++++++----------
17 1 file changed, 6 insertions(+), 10 deletions(-)
18
19 diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
20 index a75709f19ea..b137370f4f8 100644
21 --- a/eclass/python-utils-r1.eclass
22 +++ b/eclass/python-utils-r1.eclass
23 @@ -192,8 +192,8 @@ _python_set_impls() {
24 # <impl> can be in PYTHON_COMPAT or EPYTHON form. The patterns can be
25 # either:
26 # a) fnmatch-style patterns, e.g. 'python2*', 'pypy'...
27 -# b) '-2' to indicate all Python 2 variants (= !python_is_python3)
28 -# c) '-3' to indicate all Python 3 variants (= python_is_python3)
29 +# b) '-2' to indicate all Python 2 variants
30 +# c) '-3' to indicate all Python 3 variants
31 _python_impl_matches() {
32 [[ ${#} -ge 1 ]] || die "${FUNCNAME}: takes at least 1 parameter"
33 [[ ${#} -eq 1 ]] && return 0
34 @@ -203,10 +203,9 @@ _python_impl_matches() {
35
36 for pattern; do
37 if [[ ${pattern} == -2 ]]; then
38 - python_is_python3 "${impl}" || return 0
39 + :
40 elif [[ ${pattern} == -3 ]]; then
41 - python_is_python3 "${impl}" && return 0
42 - return
43 + return 0
44 # unify value style to allow lax matching
45 elif [[ ${impl/./_} == ${pattern/./_} ]]; then
46 return 0
47 @@ -919,7 +918,7 @@ _python_wrapper_setup() {
48 _python_export "${impl}" EPYTHON PYTHON
49
50 local pyver pyother
51 - if python_is_python3; then
52 + if [[ ${EPYTHON} != python2* ]]; then
53 pyver=3
54 pyother=2
55 else
56 @@ -1096,13 +1095,10 @@ python_fix_shebang() {
57 if [[ ${i} == *python2 ]]; then
58 from=python2
59 if [[ ! ${force} ]]; then
60 - python_is_python3 "${EPYTHON}" && error=1
61 + error=1
62 fi
63 elif [[ ${i} == *python3 ]]; then
64 from=python3
65 - if [[ ! ${force} ]]; then
66 - python_is_python3 "${EPYTHON}" || error=1
67 - fi
68 else
69 from=python
70 fi