diff mbox series

[RFC] tests: Switch default python version to 3

Message ID 20190212085940.3988-1-masashi.honma@gmail.com
State Accepted
Headers show
Series [RFC] tests: Switch default python version to 3 | expand

Commit Message

Masashi Honma Feb. 12, 2019, 8:59 a.m. UTC
Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
---
 tests/hwsim/run-tests.py      | 2 +-
 tests/hwsim/vm/parallel-vm.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Masashi Honma Feb. 12, 2019, 9:02 a.m. UTC | #1
On 2019/02/12 17:59, Masashi Honma wrote:
> Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
> ---
>   tests/hwsim/run-tests.py      | 2 +-
>   tests/hwsim/vm/parallel-vm.py | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/hwsim/run-tests.py b/tests/hwsim/run-tests.py
> index 43c30efae..2fe8ed866 100755
> --- a/tests/hwsim/run-tests.py
> +++ b/tests/hwsim/run-tests.py
> @@ -1,4 +1,4 @@
> -#!/usr/bin/env python2
> +#!/usr/bin/env python3
>   #
>   # Test case executor
>   # Copyright (c) 2013-2015, Jouni Malinen <j@w1.fi>
> diff --git a/tests/hwsim/vm/parallel-vm.py b/tests/hwsim/vm/parallel-vm.py
> index f597912e3..0e2a14110 100755
> --- a/tests/hwsim/vm/parallel-vm.py
> +++ b/tests/hwsim/vm/parallel-vm.py
> @@ -1,4 +1,4 @@
> -#!/usr/bin/env python2
> +#!/usr/bin/env python3
>   #
>   # Parallel VM test case executor
>   # Copyright (c) 2014-2018, Jouni Malinen <j@w1.fi>

Please merge this patch when you think it is good time.

Masashi Honma.
Jouni Malinen Feb. 12, 2019, 2:43 p.m. UTC | #2
On Tue, Feb 12, 2019 at 05:59:40PM +0900, Masashi Honma wrote:
> -#!/usr/bin/env python2
> +#!/usr/bin/env python3

Wouldn't it be nicer to not require a specific version to be used, i.e.,
change that to "python" instead of "python3"? I'm not sure how common it
is for python3 to be installed nowadays if python2 is available (I'd
guess that would be very common, but I have no data to back that
assumption), so this may not be much of a concern. Anyway, the reason
for that current "python2" there is in the scripts previously not
supporting python3.

The only benefit I see in forcing python3 here is to make it less likely
that new changes break python3 compatibility (at the cost of making it
more likely for python2 compatibility to be broken). I'd hope there
would be a nicer way of doing that, though, than moving from enforcing
one version of the language to enforcing another version.
Johannes Berg Feb. 12, 2019, 7:24 p.m. UTC | #3
On Tue, 2019-02-12 at 16:43 +0200, Jouni Malinen wrote:
> On Tue, Feb 12, 2019 at 05:59:40PM +0900, Masashi Honma wrote:
> > -#!/usr/bin/env python2
> > +#!/usr/bin/env python3
> 
> Wouldn't it be nicer to not require a specific version to be used, i.e.,
> change that to "python" instead of "python3"? I'm not sure how common it
> is for python3 to be installed nowadays if python2 is available (I'd
> guess that would be very common, but I have no data to back that
> assumption), so this may not be much of a concern. Anyway, the reason
> for that current "python2" there is in the scripts previously not
> supporting python3.

Well, for the most part, 'python' just points to 'python2' anyway, this
was also codified in python:

https://www.python.org/dev/peps/pep-0394/

 * for the time being, all distributions should ensure that python, if
   installed, refers to the same target as python2, unless the user
   deliberately overrides this or a virtual environment is active.
 * however, end users should be aware that python refers to python3 on
   at least Arch Linux (that change is what prompted the creation of
   this PEP), so python should be used in the shebang line only for
   scripts that are source compatible with both Python 2 and 3.

On the other hand, python3 is going to be available on all systems that
have it installed, and it seems likely that all distros ship it?

> The only benefit I see in forcing python3 here is to make it less likely
> that new changes break python3 compatibility (at the cost of making it
> more likely for python2 compatibility to be broken). I'd hope there
> would be a nicer way of doing that, though, than moving from enforcing
> one version of the language to enforcing another version.

I'm not sure why we should even bother supporting a language that's
going to be EOLed in less than a year though :-)

johannes
Jouni Malinen Feb. 12, 2019, 8:07 p.m. UTC | #4
On Tue, Feb 12, 2019 at 08:24:10PM +0100, Johannes Berg wrote:
> On Tue, 2019-02-12 at 16:43 +0200, Jouni Malinen wrote:
> > Wouldn't it be nicer to not require a specific version to be used, i.e.,
> > change that to "python" instead of "python3"?

> Well, for the most part, 'python' just points to 'python2' anyway, this
> was also codified in python:
> 
> https://www.python.org/dev/peps/pep-0394/
> 
>  * for the time being, all distributions should ensure that python, if
>    installed, refers to the same target as python2, unless the user
>    deliberately overrides this or a virtual environment is active.
>  * however, end users should be aware that python refers to python3 on
>    at least Arch Linux (that change is what prompted the creation of
>    this PEP), so python should be used in the shebang line only for
>    scripts that are source compatible with both Python 2 and 3.

That PEP 394 looks a bit confusing.. The more formal part of it seems to
be targeting what distros are recommended to do and I would actually
make the interpretation of python starting to point to python3 once
distros decide to deprecate or drop python2. However, that formal part
did not say that nor did it give guidance to what the scripts.

The part marked clearly as not containing official recommendations did
discuss this topic from the script view point, though. It seemed to
imply that there might be justification to using python3 instead of
python to avoid issues if a new major version of python is released
(great.. not something I'd like to think about as an acceptable way of
updating a programming language). However, what is the status of
"Migration Notes" that are not official recommendation?

> I'm not sure why we should even bother supporting a language that's
> going to be EOLed in less than a year though :-)

We'll see how long distros decide to support python2 regardless of what
the upstream project does.

Just to be clear, I'm not strongly against the changes in this patch
(well, after some more testing and likely small changes to cover test
cases that do show some difference in behavior), but I still continue to
be against this concept of a programming language mandating each program
to explicitly select a specific version of the interpreter because the
language could not be updated in a manner that would remain compatible
with existing scripts.
Jouni Malinen Feb. 18, 2019, 10:08 p.m. UTC | #5
Well, that goal of being able to maintain python2 support did not last
long.. I did not find any easy way of fixing the logger issue with UTF-8
strings under VM with python3 and after not wanting to spend any more
time with it, I ended up applying this and fixing logging in a manner
that works with python3 but apparently not python2.
Masashi Honma Feb. 19, 2019, 4:50 a.m. UTC | #6
On 2019/02/19 7:08, Jouni Malinen wrote:
 > Well, that goal of being able to maintain python2 support did not last
 > long.. I did not find any easy way of fixing the logger issue with UTF-8
 > strings under VM with python3 and after not wanting to spend any more
 > time with it, I ended up applying this and fixing logging in a manner
 > that works with python3

Thank you !

 > but apparently not python2.

I also have tried to find out the good way until previous modification,
though I could not.

Your fix does not cause test failure. So I think it does not breaks
backward compatibility.

Masashi Honma.
diff mbox series

Patch

diff --git a/tests/hwsim/run-tests.py b/tests/hwsim/run-tests.py
index 43c30efae..2fe8ed866 100755
--- a/tests/hwsim/run-tests.py
+++ b/tests/hwsim/run-tests.py
@@ -1,4 +1,4 @@ 
-#!/usr/bin/env python2
+#!/usr/bin/env python3
 #
 # Test case executor
 # Copyright (c) 2013-2015, Jouni Malinen <j@w1.fi>
diff --git a/tests/hwsim/vm/parallel-vm.py b/tests/hwsim/vm/parallel-vm.py
index f597912e3..0e2a14110 100755
--- a/tests/hwsim/vm/parallel-vm.py
+++ b/tests/hwsim/vm/parallel-vm.py
@@ -1,4 +1,4 @@ 
-#!/usr/bin/env python2
+#!/usr/bin/env python3
 #
 # Parallel VM test case executor
 # Copyright (c) 2014-2018, Jouni Malinen <j@w1.fi>