On Wed, 16 Jan 2019 21:53:36 +0530 Seeteena Thoufeek <[email protected]> wrote:
> Support both Python 2 and Python 3 in mem-phys-addr.py. ``print`` is now a > function rather than a statement. This should have no functional change. > > Fix lambda syntax error. So, I just picked one of these at random.... > Signed-off-by: Seeteena Thoufeek <[email protected]> > Reviewed-by: Ravi Bangoria <[email protected]> > --- > tools/perf/scripts/python/mem-phys-addr.py | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/tools/perf/scripts/python/mem-phys-addr.py > b/tools/perf/scripts/python/mem-phys-addr.py > index ebee2c5..52fe9bd 100644 > --- a/tools/perf/scripts/python/mem-phys-addr.py > +++ b/tools/perf/scripts/python/mem-phys-addr.py > @@ -38,14 +38,14 @@ def parse_iomem(): > pmem.append(long(m[1], 16)) > > def print_memory_type(): > - print "Event: %s" % (event_name) > - print "%-40s %10s %10s\n" % ("Memory type", "count", "percentage"), > - print "%-40s %10s %10s\n" % > ("----------------------------------------", \ > - "-----------", "-----------"), > + print("Event: %s" % (event_name)) > + print("%-40s %10s %10s\n" % ("Memory type", "count", "percentage")), > + print("%-40s %10s %10s\n" % > ("----------------------------------------", \ > + "-----------", "-----------")), You have not added "from __future__ import print_function", so you're relying on a Python 2 parsing oddity to make this work. If anybody ever adds a second parameter, things will break. I think that if you really want to support both versions (which seems like the right goal) you should add the import and do it properly. Thanks, jon

