[ovs-dev] [unixctl_py 5/6] python: Add ovs_error() helper function to Python.

Ben Pfaff blp at nicira.com
Mon Mar 5 21:59:56 UTC 2012


I think Reid is just saying that "if not retval:" accepts more than
just 0.  It also treats None, "", (), and [], for example, as false.

On Mon, Mar 05, 2012 at 01:57:05PM -0800, Ethan Jackson wrote:
> I'm sorry, I don't fully understand what you're suggesting.  Could you
> please give an example of a piece of code that should change?
> 
> Based on my reading of the code, when there's an error we return a
> non-zero errno.  The errno is always an integer type.  Sometimes in
> addition to the errno we return some additional information, but that
> isn't used for checking error conditions.
> 
> Ethan
> 
> On Sun, Mar 4, 2012 at 21:23, Reid Price <reid at nicira.com> wrote:
> > One other note, are you deliberately allowing None (along with other python
> > expressions that are False as booleans) to equate to a 0 return code?  You
> > may just want to check for integer type at the beginning of the function,
> > since
> > things compare across type without error (for error-free sorting purposes,
> > ostensibly).  E.g.:
> >
> > {1: 2} > 0 == True
> > "string" > 0 == True
> >
> > Some things will throw TypeErrors for the >0, like sets and complex numbers.
> >
> >   -Reid
> >
> > On Thu, Mar 1, 2012 at 5:40 PM, Ethan Jackson <ethan at nicira.com> wrote:
> >>
> >> > In the final case in ovs_retval_to_string(), I think I'd use %s
> >> > instead of %d: maybe some non-integer value got passed in and my
> >> > instinct is that it's probably better to convert it to a string than
> >> > to throw an exception.
> >>
> >> Sounds good, I've folded the change in.
> >>
> >> Ethan
> >> _______________________________________________
> >> dev mailing list
> >> dev at openvswitch.org
> >> http://openvswitch.org/mailman/listinfo/dev
> >
> >



More information about the dev mailing list