[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <a9fea5f9-752d-e069-bd17-31fabe258a20@suse.de>
Date: Mon, 21 Jan 2019 09:38:11 -0800
From: Tony Jones <tonyj@...e.de>
To: Seeteena Thoufeek <s1seetee@...ux.vnet.ibm.com>,
peterz@...radead.org, mingo@...hat.com, acme@...nel.org,
alexander.shishkin@...ux.intel.com, jolsa@...hat.com,
namhyung@...nel.org, linux-kernel@...r.kernel.org,
ravi.bangoria@...ux.ibm.com
Subject: Re: [PATCH v3] perf scripts python: Add Python 3 support to
export-to-sqlite.py
On 1/21/19 2:39 AM, Seeteena Thoufeek wrote:
> Support both Python 2 and Python 3 in export-to-sqlite.py. ``print`` is
> now a function rather than a statement. This should have no functional
> change.
>
> Also, handles the conversion of "print >> sys.stderr".
>
> Signed-off-by: Seeteena Thoufeek <s1seetee@...ux.vnet.ibm.com>
> Reviewed-by: Ravi Bangoria <ravi.bangoria@...ux.ibm.com>
> ---
> tools/perf/scripts/python/export-to-sqlite.py | 19 ++++++++++---------
> 1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/tools/perf/scripts/python/export-to-sqlite.py b/tools/perf/scripts/python/export-to-sqlite.py
> index 245caf2..95bfcb2 100644
> --- a/tools/perf/scripts/python/export-to-sqlite.py
> +++ b/tools/perf/scripts/python/export-to-sqlite.py
> @@ -9,6 +9,7 @@
> # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
> # more details.
> +from __future__ import print_function
So is the script failing for you without the above
As I said in previous reviews you should not need this unless you are using features of the latest print function (end, sep etc). You will need this import in the other scripts (once you fix the numerous errors regarding the trailing comma usage) as some need to concatenate output onto one line but I don't think you need it here.
tony
$ python2 --version
Python 2.7.15
$ python3 --version
Python 3.6.5
$ a='print("abcd") ; print("defg")'
$ echo $a | python2
abcd
defg
$ echo $a | python3
abcd
defg
$ b='print("abcd", end="") ; print("defg")'
$ echo $b | python2
File "<stdin>", line 1
print("abcd", end="") ; print("defg")
^
SyntaxError: invalid syntax
$ echo $b | python3
abcddefg
$ c='from __future__ import print_function ; print("abcd", end="") ; print("defg")'
$ echo $c | python2
abcddefg
$ echo $c | python3
abcddefg
Powered by blists - more mailing lists