diff mbox series

host-tools: use python2 explicitly for shebang

Message ID 1516527297-10969-1-git-send-email-yamada.masahiro@socionext.com
State Accepted
Commit 94b13bbae90bfb94204b8fe9c531bc163e746a9f
Headers show
Series host-tools: use python2 explicitly for shebang | expand

Commit Message

Masahiro Yamada Jan. 21, 2018, 9:34 a.m. UTC
All of these host tools are apparently written for Python2,
not Python3.

Use 'python2' in the shebang line according to PEP 394
(https://www.python.org/dev/peps/pep-0394/).

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

I sent some time before figuring out why Patman does not work
on my machine.

If 'python' points to python3, Patman does not epit any error
message, it just stays silent until it consumes all memory
on the system.


 scripts/dtc/pylibfdt/setup.py | 2 +-
 scripts/mailmapper            | 2 +-
 test/py/test.py               | 2 +-
 tools/buildman/buildman.py    | 2 +-
 tools/dtoc/dtoc.py            | 2 +-
 tools/microcode-tool.py       | 2 +-
 tools/patman/patman.py        | 2 +-
 tools/rkmux.py                | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

Comments

Simon Glass Jan. 26, 2018, 3:27 p.m. UTC | #1
Hi Masahiro,

On 21 January 2018 at 02:34, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> All of these host tools are apparently written for Python2,
> not Python3.
>
> Use 'python2' in the shebang line according to PEP 394
> (https://www.python.org/dev/peps/pep-0394/).
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
> I sent some time before figuring out why Patman does not work
> on my machine.
>
> If 'python' points to python3, Patman does not epit any error
> message, it just stays silent until it consumes all memory
> on the system.
>
>
>  scripts/dtc/pylibfdt/setup.py | 2 +-
>  scripts/mailmapper            | 2 +-
>  test/py/test.py               | 2 +-
>  tools/buildman/buildman.py    | 2 +-
>  tools/dtoc/dtoc.py            | 2 +-
>  tools/microcode-tool.py       | 2 +-
>  tools/patman/patman.py        | 2 +-
>  tools/rkmux.py                | 2 +-
>  8 files changed, 8 insertions(+), 8 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

I can repeat that problem. There has been some effort to make patman
(in particular) work with python 3. Should we fix the bug? This change
will mask it.

Regards,
Simon
Masahiro Yamada Jan. 27, 2018, 9:28 p.m. UTC | #2
Hi Simon,


2018-01-27 0:27 GMT+09:00 Simon Glass <sjg@chromium.org>:
> Hi Masahiro,
>
> On 21 January 2018 at 02:34, Masahiro Yamada
> <yamada.masahiro@socionext.com> wrote:
>> All of these host tools are apparently written for Python2,
>> not Python3.
>>
>> Use 'python2' in the shebang line according to PEP 394
>> (https://www.python.org/dev/peps/pep-0394/).
>>
>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>> ---
>>
>> I sent some time before figuring out why Patman does not work
>> on my machine.
>>
>> If 'python' points to python3, Patman does not epit any error
>> message, it just stays silent until it consumes all memory
>> on the system.
>>
>>
>>  scripts/dtc/pylibfdt/setup.py | 2 +-
>>  scripts/mailmapper            | 2 +-
>>  test/py/test.py               | 2 +-
>>  tools/buildman/buildman.py    | 2 +-
>>  tools/dtoc/dtoc.py            | 2 +-
>>  tools/microcode-tool.py       | 2 +-
>>  tools/patman/patman.py        | 2 +-
>>  tools/rkmux.py                | 2 +-
>>  8 files changed, 8 insertions(+), 8 deletions(-)
>
> Reviewed-by: Simon Glass <sjg@chromium.org>
>
> I can repeat that problem. There has been some effort to make patman
> (in particular) work with python 3. Should we fix the bug? This change
> will mask it.
>

I do not think this is a bug.

If 'python2' is specified in the shebang line,
users should not run it under python 3.

Python 2 will retire in 2020
(https://pythonclock.org/),
we need to covert our python scripts
to python 3 at some point in the future.
'2to3' tool is useful, but not perfect.
Then, we will need to take a look into problems
during the conversion.

Also, I believe we should use python 2 only for existing tools.
New python scripts should be all written in python 3.
(If they are written in python 2,
should be rejected in the review.)
Tom Rini Jan. 28, 2018, 6:53 p.m. UTC | #3
On Sun, Jan 21, 2018 at 06:34:57PM +0900, Masahiro Yamada wrote:

> All of these host tools are apparently written for Python2,

> not Python3.

> 

> Use 'python2' in the shebang line according to PEP 394

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

> 

> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

> Reviewed-by: Simon Glass <sjg@chromium.org>


Applied to u-boot/master, thanks!

-- 
Tom
Simon Glass Jan. 29, 2018, 4:26 a.m. UTC | #4
Hi Masahiro,

On 27 January 2018 at 14:28, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> Hi Simon,
>
>
> 2018-01-27 0:27 GMT+09:00 Simon Glass <sjg@chromium.org>:
>> Hi Masahiro,
>>
>> On 21 January 2018 at 02:34, Masahiro Yamada
>> <yamada.masahiro@socionext.com> wrote:
>>> All of these host tools are apparently written for Python2,
>>> not Python3.
>>>
>>> Use 'python2' in the shebang line according to PEP 394
>>> (https://www.python.org/dev/peps/pep-0394/).
>>>
>>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>>> ---
>>>
>>> I sent some time before figuring out why Patman does not work
>>> on my machine.
>>>
>>> If 'python' points to python3, Patman does not epit any error
>>> message, it just stays silent until it consumes all memory
>>> on the system.
>>>
>>>
>>>  scripts/dtc/pylibfdt/setup.py | 2 +-
>>>  scripts/mailmapper            | 2 +-
>>>  test/py/test.py               | 2 +-
>>>  tools/buildman/buildman.py    | 2 +-
>>>  tools/dtoc/dtoc.py            | 2 +-
>>>  tools/microcode-tool.py       | 2 +-
>>>  tools/patman/patman.py        | 2 +-
>>>  tools/rkmux.py                | 2 +-
>>>  8 files changed, 8 insertions(+), 8 deletions(-)
>>
>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>
>> I can repeat that problem. There has been some effort to make patman
>> (in particular) work with python 3. Should we fix the bug? This change
>> will mask it.
>>
>
> I do not think this is a bug.
>
> If 'python2' is specified in the shebang line,
> users should not run it under python 3.

I mean the bug that makes patman hang. I thought that patman ran with
Python 3. It has been converted but apparently does not run.

>
> Python 2 will retire in 2020
> (https://pythonclock.org/),
> we need to covert our python scripts
> to python 3 at some point in the future.
> '2to3' tool is useful, but not perfect.
> Then, we will need to take a look into problems
> during the conversion.
>
> Also, I believe we should use python 2 only for existing tools.
> New python scripts should be all written in python 3.
> (If they are written in python 2,
> should be rejected in the review.)

That sounds OK to me, but I think we should convert existing tools too.

Regards,
Simon
Masahiro Yamada Jan. 29, 2018, 4:42 a.m. UTC | #5
2018-01-29 13:26 GMT+09:00 Simon Glass <sjg@chromium.org>:
> Hi Masahiro,
>
> On 27 January 2018 at 14:28, Masahiro Yamada
> <yamada.masahiro@socionext.com> wrote:
>> Hi Simon,
>>
>>
>> 2018-01-27 0:27 GMT+09:00 Simon Glass <sjg@chromium.org>:
>>> Hi Masahiro,
>>>
>>> On 21 January 2018 at 02:34, Masahiro Yamada
>>> <yamada.masahiro@socionext.com> wrote:
>>>> All of these host tools are apparently written for Python2,
>>>> not Python3.
>>>>
>>>> Use 'python2' in the shebang line according to PEP 394
>>>> (https://www.python.org/dev/peps/pep-0394/).
>>>>
>>>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>>>> ---
>>>>
>>>> I sent some time before figuring out why Patman does not work
>>>> on my machine.
>>>>
>>>> If 'python' points to python3, Patman does not epit any error
>>>> message, it just stays silent until it consumes all memory
>>>> on the system.
>>>>
>>>>
>>>>  scripts/dtc/pylibfdt/setup.py | 2 +-
>>>>  scripts/mailmapper            | 2 +-
>>>>  test/py/test.py               | 2 +-
>>>>  tools/buildman/buildman.py    | 2 +-
>>>>  tools/dtoc/dtoc.py            | 2 +-
>>>>  tools/microcode-tool.py       | 2 +-
>>>>  tools/patman/patman.py        | 2 +-
>>>>  tools/rkmux.py                | 2 +-
>>>>  8 files changed, 8 insertions(+), 8 deletions(-)
>>>
>>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>>
>>> I can repeat that problem. There has been some effort to make patman
>>> (in particular) work with python 3. Should we fix the bug? This change
>>> will mask it.
>>>
>>
>> I do not think this is a bug.
>>
>> If 'python2' is specified in the shebang line,
>> users should not run it under python 3.
>
> I mean the bug that makes patman hang. I thought that patman ran with
> Python 3. It has been converted but apparently does not run.


I was misunderstanding.

I thought patman was expected to work only for python2.

From the following commits, the intention was
it was compatible both python 2 and python 3.

commit 2ce7b21e6c98301f9b05daac076db33d498cfbe1
Author: Paul Burton <paul.burton@imgtec.com>
Date:   Tue Sep 27 16:03:52 2016 +0100

    patman: Import 'configparser' lower case to be python 3.x safe

commit ac3fde9394ce90503930026c62ffd94bf7fa09fd
Author: Paul Burton <paul.burton@imgtec.com>
Date:   Tue Sep 27 16:03:51 2016 +0100

    patman: Make exception handling python 3.x safe

commit a920a17b2f418535870788ae81234dc6b8aa6661
Author: Paul Burton <paul.burton@imgtec.com>
Date:   Tue Sep 27 16:03:50 2016 +0100

    patman: Make print statements python 3.x safe



Anybody who has ever tested it really on python 3?
Simon Glass Feb. 4, 2018, 1:40 p.m. UTC | #6
Hi Masahiro,

On 28 January 2018 at 21:42, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> 2018-01-29 13:26 GMT+09:00 Simon Glass <sjg@chromium.org>:
>> Hi Masahiro,
>>
>> On 27 January 2018 at 14:28, Masahiro Yamada
>> <yamada.masahiro@socionext.com> wrote:
>>> Hi Simon,
>>>
>>>
>>> 2018-01-27 0:27 GMT+09:00 Simon Glass <sjg@chromium.org>:
>>>> Hi Masahiro,
>>>>
>>>> On 21 January 2018 at 02:34, Masahiro Yamada
>>>> <yamada.masahiro@socionext.com> wrote:
>>>>> All of these host tools are apparently written for Python2,
>>>>> not Python3.
>>>>>
>>>>> Use 'python2' in the shebang line according to PEP 394
>>>>> (https://www.python.org/dev/peps/pep-0394/).
>>>>>
>>>>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>>>>> ---
>>>>>
>>>>> I sent some time before figuring out why Patman does not work
>>>>> on my machine.
>>>>>
>>>>> If 'python' points to python3, Patman does not epit any error
>>>>> message, it just stays silent until it consumes all memory
>>>>> on the system.
>>>>>
>>>>>
>>>>>  scripts/dtc/pylibfdt/setup.py | 2 +-
>>>>>  scripts/mailmapper            | 2 +-
>>>>>  test/py/test.py               | 2 +-
>>>>>  tools/buildman/buildman.py    | 2 +-
>>>>>  tools/dtoc/dtoc.py            | 2 +-
>>>>>  tools/microcode-tool.py       | 2 +-
>>>>>  tools/patman/patman.py        | 2 +-
>>>>>  tools/rkmux.py                | 2 +-
>>>>>  8 files changed, 8 insertions(+), 8 deletions(-)
>>>>
>>>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>>>
>>>> I can repeat that problem. There has been some effort to make patman
>>>> (in particular) work with python 3. Should we fix the bug? This change
>>>> will mask it.
>>>>
>>>
>>> I do not think this is a bug.
>>>
>>> If 'python2' is specified in the shebang line,
>>> users should not run it under python 3.
>>
>> I mean the bug that makes patman hang. I thought that patman ran with
>> Python 3. It has been converted but apparently does not run.
>
>
> I was misunderstanding.
>
> I thought patman was expected to work only for python2.
>
> From the following commits, the intention was
> it was compatible both python 2 and python 3.
>
> commit 2ce7b21e6c98301f9b05daac076db33d498cfbe1
> Author: Paul Burton <paul.burton@imgtec.com>
> Date:   Tue Sep 27 16:03:52 2016 +0100
>
>     patman: Import 'configparser' lower case to be python 3.x safe
>
> commit ac3fde9394ce90503930026c62ffd94bf7fa09fd
> Author: Paul Burton <paul.burton@imgtec.com>
> Date:   Tue Sep 27 16:03:51 2016 +0100
>
>     patman: Make exception handling python 3.x safe
>
> commit a920a17b2f418535870788ae81234dc6b8aa6661
> Author: Paul Burton <paul.burton@imgtec.com>
> Date:   Tue Sep 27 16:03:50 2016 +0100
>
>     patman: Make print statements python 3.x safe
>
>
>
> Anybody who has ever tested it really on python 3?

I did think that it worked at one point, but I am not sure.

Regards,
Simon
diff mbox series

Patch

diff --git a/scripts/dtc/pylibfdt/setup.py b/scripts/dtc/pylibfdt/setup.py
index daf1089..4f7cf04 100755
--- a/scripts/dtc/pylibfdt/setup.py
+++ b/scripts/dtc/pylibfdt/setup.py
@@ -1,4 +1,4 @@ 
-#!/usr/bin/env python
+#!/usr/bin/env python2
 
 """
 setup.py file for SWIG libfdt
diff --git a/scripts/mailmapper b/scripts/mailmapper
index 922ada6..78b23d1 100755
--- a/scripts/mailmapper
+++ b/scripts/mailmapper
@@ -1,4 +1,4 @@ 
-#!/usr/bin/env python
+#!/usr/bin/env python2
 #
 # Copyright (C) 2014, Masahiro Yamada <yamada.m@jp.panasonic.com>
 #
diff --git a/test/py/test.py b/test/py/test.py
index 74e560a..4695079 100755
--- a/test/py/test.py
+++ b/test/py/test.py
@@ -1,4 +1,4 @@ 
-#!/usr/bin/env python
+#!/usr/bin/env python2
 
 # Copyright (c) 2015 Stephen Warren
 # Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
diff --git a/tools/buildman/buildman.py b/tools/buildman/buildman.py
index 11a4f16..473117c 100755
--- a/tools/buildman/buildman.py
+++ b/tools/buildman/buildman.py
@@ -1,4 +1,4 @@ 
-#!/usr/bin/env python
+#!/usr/bin/env python2
 #
 # Copyright (c) 2012 The Chromium OS Authors.
 #
diff --git a/tools/dtoc/dtoc.py b/tools/dtoc/dtoc.py
index ce7bc05..6eacfc9 100755
--- a/tools/dtoc/dtoc.py
+++ b/tools/dtoc/dtoc.py
@@ -1,4 +1,4 @@ 
-#!/usr/bin/python
+#!/usr/bin/env python2
 #
 # Copyright (C) 2016 Google, Inc
 # Written by Simon Glass <sjg@chromium.org>
diff --git a/tools/microcode-tool.py b/tools/microcode-tool.py
index 790c27e..069d961 100755
--- a/tools/microcode-tool.py
+++ b/tools/microcode-tool.py
@@ -1,4 +1,4 @@ 
-#!/usr/bin/env python
+#!/usr/bin/env python2
 #
 # Copyright (c) 2014 Google, Inc
 #
diff --git a/tools/patman/patman.py b/tools/patman/patman.py
index 4b3bc78..7647440 100755
--- a/tools/patman/patman.py
+++ b/tools/patman/patman.py
@@ -1,4 +1,4 @@ 
-#!/usr/bin/env python
+#!/usr/bin/env python2
 #
 # Copyright (c) 2011 The Chromium OS Authors.
 #
diff --git a/tools/rkmux.py b/tools/rkmux.py
index 3917335..11c192a 100755
--- a/tools/rkmux.py
+++ b/tools/rkmux.py
@@ -1,4 +1,4 @@ 
-#!/usr/bin/python
+#!/usr/bin/env python2
 
 # Script to create enums from datasheet register tables
 #