[ovs-dev] [PATCH v2 0/2] python/ovs: add tcp socket support

Isaku Yamahata yamahata at valinux.co.jp
Mon Oct 15 21:57:27 UTC 2012


On Mon, Oct 15, 2012 at 12:10:16PM -0700, Reid Price wrote:
> I see that Ben already reviewed and pushed, only saw a comment-typo
> and a message-typo that Ben seems to have seen.  My only nit would be
> using some generic Error for the parameter checking (ValueError, or
> ovs-specific) instead of raising Exception. The register decorators /
> helper classes seem reasonable and clean, if a little overkill
> compared to a conditional in open().  Thanks!

Thank you for review. Here's the patch to replace Exception with ValueError.


>From f6d5fceeb2d9eda8ec82942541530ce1a6b26cf3 Mon Sep 17 00:00:00 2001
Message-Id: <f6d5fceeb2d9eda8ec82942541530ce1a6b26cf3.1350338202.git.yamahata at valinux.co.jp>
From: Isaku Yamahata <yamahata at valinux.co.jp>
Date: Tue, 16 Oct 2012 06:46:07 +0900
Subject: [PATCH] python/ovs/socket_util: don't use Exception, but ValueError

67656b9ff297f305b3bfcca2868e8e870e108283
used Exception, but it should be more specific error as Reid Pointed out.
Use ValueError instread of Exception.

Signed-off-by: Isaku Yamahata <yamahata at valinux.co.jp>
---
 python/ovs/socket_util.py |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/python/ovs/socket_util.py b/python/ovs/socket_util.py
index 845511e..dd45fe4 100644
--- a/python/ovs/socket_util.py
+++ b/python/ovs/socket_util.py
@@ -88,13 +88,13 @@ def inet_parse_active(target, default_port):
     address = target.split(":")
     host_name = address[0]
     if not host_name:
-        raise Exception("%s: bad peer name format" % target)
+        raise ValueError("%s: bad peer name format" % target)
     if len(address) >= 2:
         port = int(address[1])
     elif default_port:
         port = default_port
     else:
-        raise Exception("%s: port number must be specified" % target)
+        raise ValueError("%s: port number must be specified" % target)
     return (host_name, port)
 
 
@@ -187,6 +187,6 @@ def set_nonblocking(sock):
 
 def set_dscp(sock, dscp):
     if dscp > 63:
-        raise Exception("Invalid dscp %d" % dscp)
+        raise ValueError("Invalid dscp %d" % dscp)
     val = dscp << 2
     sock.setsockopt(socket.IPPROTO_IP, socket.IP_TOS, val)
-- 
1.7.10.4




-- 
yamahata



More information about the dev mailing list