Re: [PATCH nft v5] tests: py: fix python3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 28, 2019 at 09:57:37PM +0530, Shivani Bhardwaj wrote:
> On Tue, May 28, 2019 at 5:21 AM Shekhar Sharma <shekhar250198@xxxxxxxxx> wrote:
> >
> > This patch converts the 'nft-test.py' file to run on both python 2 and python3.
> >
> > The version hystory of this patch is:
> > v1:conversion to py3 by changing the print statements.
> > v2:add the '__future__' package for compatibility with py2 and py3.
> > v3:solves the 'version' problem in argparse by adding a new argument.
> > v4:uses .format() method to make print statements clearer.
> > v5: updated the shebang and corrected the sequence of import statements.
> >
> >
> > Signed-off-by: Shekhar Sharma <shekhar250198@xxxxxxxxx>
> > ---
> >  tests/py/nft-test.py | 44 +++++++++++++++++++++++---------------------
> >  1 file changed, 23 insertions(+), 21 deletions(-)
> >
> > diff --git a/tests/py/nft-test.py b/tests/py/nft-test.py
> > index 1c0afd0e..fe56340c 100755
> > --- a/tests/py/nft-test.py
> > +++ b/tests/py/nft-test.py
> > @@ -1,4 +1,4 @@
> > -#!/usr/bin/python2
> > +#!/usr/bin/python
> >  #
> >  # (C) 2014 by Ana Rey Botello <anarey@xxxxxxxxx>
> >  #
> > @@ -13,6 +13,7 @@
> >  # Thanks to the Outreach Program for Women (OPW) for sponsoring this test
> >  # infrastructure.
> >
> > +from __future__ import print_function
> >  import sys
> >  import os
> >  import argparse
> > @@ -436,7 +437,7 @@ def set_delete(table, filename=None, lineno=None):
> >      '''
> >      Deletes set and its content.
> >      '''
> > -    for set_name in all_set.keys():
> > +    for set_name in list(all_set.keys()):
> What exactly is this list() for? This is not a generator expression.

I think it's a generic python2 to python3 porting idiom to cover the
case in which the set you're iterating over is being modified inside the
for loop. However, that does not appear to the be the case here.



[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux