lkml.org 
[lkml]   [2019]   [Jan]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2] perf scripts python: Add Python 3 support to export-to-sqlite.py
From
Date
On 1/17/19 1:45 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.

I don't see any changes handling the following:

$ git annotate tools/perf/scripts/python/export-to-sqlite.py | grep ">> sys"
564b9527d1ccf (Adrian Hunter 2017-08-03 11:31:28 +0300 64) print >> sys.stderr, "Usage is: export-to-sqlite.py <database name> [<columns>] [<calls>] [<callchains>]"
564b9527d1ccf (Adrian Hunter 2017-08-03 11:31:28 +0300 65) print >> sys.stderr, "where: columns 'all' or 'branches'"
564b9527d1ccf (Adrian Hunter 2017-08-03 11:31:28 +0300 66) print >> sys.stderr, " calls 'calls' => create calls and call_paths table"
564b9527d1ccf (Adrian Hunter 2017-08-03 11:31:28 +0300 67) print >> sys.stderr, " callchains 'callchains' => create call_paths table"

$ echo 'import sys ; print >> sys.stderr, "Usage is: exported-sql-viewer.py {<database name> | --help-only}"' | python2
Usage is: exported-sql-viewer.py {<database name> | --help-only}

$ echo 'import sys ; print >> sys.stderr, "Usage is: exported-sql-viewer.py {<database name> | --help-only}"' | python3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for >>: 'builtin_function_or_method' and '_io.TextIOWrapper'. Did you mean "print(<message>, file=<output_stream>)"?


They are best handled via conversion to sys.stderr.write() since sys is already imported.

Tony

\
 
 \ /
  Last update: 2019-01-19 02:06    [W:0.157 / U:0.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site