* [PATCH nft v1 ] py: nftables.py: fix python3
@ 2019-05-24 18:49 Shekhar Sharma
2019-05-28 14:09 ` Eric Garver
0 siblings, 1 reply; 3+ messages in thread
From: Shekhar Sharma @ 2019-05-24 18:49 UTC (permalink / raw)
To: netfilter-devel; +Cc: Shekhar Sharma
This patch converts the 'nftables.py' file (nftables/py/nftables.py) to run on both python2 and python3.
Signed-off-by: Shekhar Sharma <shekhar250198@gmail.com>
---
py/nftables.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/py/nftables.py b/py/nftables.py
index 33cd2dfd..badcfa5c 100644
--- a/py/nftables.py
+++ b/py/nftables.py
@@ -297,7 +297,7 @@ class Nftables:
val = self.nft_ctx_output_get_debug(self.__ctx)
names = []
- for n,v in self.debug_flags.items():
+ for n,v in list(self.debug_flags.items()):
if val & v:
names.append(n)
val &= ~v
--
2.21.0.windows.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH nft v1 ] py: nftables.py: fix python3
2019-05-24 18:49 [PATCH nft v1 ] py: nftables.py: fix python3 Shekhar Sharma
@ 2019-05-28 14:09 ` Eric Garver
2019-05-28 14:15 ` shekhar sharma
0 siblings, 1 reply; 3+ messages in thread
From: Eric Garver @ 2019-05-28 14:09 UTC (permalink / raw)
To: Shekhar Sharma; +Cc: netfilter-devel
On Sat, May 25, 2019 at 12:19:50AM +0530, Shekhar Sharma wrote:
> This patch converts the 'nftables.py' file (nftables/py/nftables.py) to run on both python2 and python3.
>
>
> Signed-off-by: Shekhar Sharma <shekhar250198@gmail.com>
> ---
> py/nftables.py | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/py/nftables.py b/py/nftables.py
> index 33cd2dfd..badcfa5c 100644
> --- a/py/nftables.py
> +++ b/py/nftables.py
> @@ -297,7 +297,7 @@ class Nftables:
> val = self.nft_ctx_output_get_debug(self.__ctx)
>
> names = []
> - for n,v in self.debug_flags.items():
> + for n,v in list(self.debug_flags.items()):
> if val & v:
> names.append(n)
> val &= ~v
Are you fixing an issue here? I don't think the conversion to list is
necessary. The dictionary view can still be iterated. The dictionary is
not being modified.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH nft v1 ] py: nftables.py: fix python3
2019-05-28 14:09 ` Eric Garver
@ 2019-05-28 14:15 ` shekhar sharma
0 siblings, 0 replies; 3+ messages in thread
From: shekhar sharma @ 2019-05-28 14:15 UTC (permalink / raw)
To: Eric Garver, Shekhar Sharma, netfilter-devel
On Tue, May 28, 2019 at 7:40 PM Eric Garver <eric@garver.life> wrote:
>
> On Sat, May 25, 2019 at 12:19:50AM +0530, Shekhar Sharma wrote:
> > This patch converts the 'nftables.py' file (nftables/py/nftables.py) to run on both python2 and python3.
> >
> >
> > Signed-off-by: Shekhar Sharma <shekhar250198@gmail.com>
> > ---
> > py/nftables.py | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/py/nftables.py b/py/nftables.py
> > index 33cd2dfd..badcfa5c 100644
> > --- a/py/nftables.py
> > +++ b/py/nftables.py
> > @@ -297,7 +297,7 @@ class Nftables:
> > val = self.nft_ctx_output_get_debug(self.__ctx)
> >
> > names = []
> > - for n,v in self.debug_flags.items():
> > + for n,v in list(self.debug_flags.items()):
> > if val & v:
> > names.append(n)
> > val &= ~v
>
> Are you fixing an issue here? I don't think the conversion to list is
> necessary. The dictionary view can still be iterated. The dictionary is
> not being modified.
Yes, when i compiled the code with python3 in my computer, it ran
without the conversion to list
but when i used an online compiler, it complained about it and i read
online that methods like .items and .keys()
do not return iterables in python3 as they do in python2.
I think the conversion is not necessary. We can omit it.
Shekhar
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-05-28 14:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-24 18:49 [PATCH nft v1 ] py: nftables.py: fix python3 Shekhar Sharma
2019-05-28 14:09 ` Eric Garver
2019-05-28 14:15 ` shekhar sharma
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).