[ovs-dev,1/3] tests/sendpkt.py: Fix to work with Python3

Message ID 55649da6719f0e46bf50e49022f79beb5518f8ab.1527705975.git.tredaelli@redhat.com
State Accepted
Headers show
Series
  • Permit to build OVS with only Python3 installed
Related show

Commit Message

Timothy Redaelli May 31, 2018, 2:52 p.m.
CC: Ashish Varma <ashishvarma.ovs@gmail.com>
Fixes: 296251ca0c82 ("tests: Added NSH related unit test cases for datapath")
Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
---
 tests/sendpkt.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Ashish Varma June 4, 2018, 10:21 p.m. | #1
Acked-by: Ashish Varma <ashishvarma.ovs@gmail.com <u9012063@gmail.com>>

On Thu, May 31, 2018 at 7:52 AM, Timothy Redaelli <tredaelli@redhat.com>
wrote:

> CC: Ashish Varma <ashishvarma.ovs@gmail.com>
> Fixes: 296251ca0c82 ("tests: Added NSH related unit test cases for
> datapath")
> Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
> ---
>  tests/sendpkt.py | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tests/sendpkt.py b/tests/sendpkt.py
> index 50a4795eb..328ae2bc9 100755
> --- a/tests/sendpkt.py
> +++ b/tests/sendpkt.py
> @@ -66,7 +66,10 @@ for a in args[1:]:
>
>      hex_list.append(temp)
>
> -pkt = "".join(map(chr, hex_list))
> +if sys.version_info < (3, 0):
> +    pkt = "".join(map(chr, hex_list))
> +else:
> +    pkt = bytes(hex_list)
>
>  try:
>      sockfd = socket.socket(socket.AF_PACKET, socket.SOCK_RAW)
> --
> 2.17.0
>
>
Ben Pfaff June 14, 2018, 8:49 p.m. | #2
Thanks Timothy (and Ashish).  I applied this to master.

On Mon, Jun 04, 2018 at 03:21:46PM -0700, Ashish Varma wrote:
> Acked-by: Ashish Varma <ashishvarma.ovs@gmail.com <u9012063@gmail.com>>
> 
> On Thu, May 31, 2018 at 7:52 AM, Timothy Redaelli <tredaelli@redhat.com>
> wrote:
> 
> > CC: Ashish Varma <ashishvarma.ovs@gmail.com>
> > Fixes: 296251ca0c82 ("tests: Added NSH related unit test cases for
> > datapath")
> > Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
> > ---
> >  tests/sendpkt.py | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/tests/sendpkt.py b/tests/sendpkt.py
> > index 50a4795eb..328ae2bc9 100755
> > --- a/tests/sendpkt.py
> > +++ b/tests/sendpkt.py
> > @@ -66,7 +66,10 @@ for a in args[1:]:
> >
> >      hex_list.append(temp)
> >
> > -pkt = "".join(map(chr, hex_list))
> > +if sys.version_info < (3, 0):
> > +    pkt = "".join(map(chr, hex_list))
> > +else:
> > +    pkt = bytes(hex_list)
> >
> >  try:
> >      sockfd = socket.socket(socket.AF_PACKET, socket.SOCK_RAW)
> > --
> > 2.17.0
> >
> >
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Patch

diff --git a/tests/sendpkt.py b/tests/sendpkt.py
index 50a4795eb..328ae2bc9 100755
--- a/tests/sendpkt.py
+++ b/tests/sendpkt.py
@@ -66,7 +66,10 @@  for a in args[1:]:
 
     hex_list.append(temp)
 
-pkt = "".join(map(chr, hex_list))
+if sys.version_info < (3, 0):
+    pkt = "".join(map(chr, hex_list))
+else:
+    pkt = bytes(hex_list)
 
 try:
     sockfd = socket.socket(socket.AF_PACKET, socket.SOCK_RAW)