klipstein/dojango — Issue #55: 55 - modelstore ValueMethod: "None" value check does not work as expected 
Author: klipstein
Created: 2011-11-06 13:01:14+00:00
State: open

What is the expected output? What do you see instead?

at data/modelstore/methods.py:294, you can see the following code:

{{{
# Prevent throwing a MethodException if the value is None
return (val is None) and None or self.get_method(val)(*self.args, **self.kwargs)
}}}

This is broken in the sense "(val is None) and None" is still evaluating to False when val is None. This makes the return value be the right hand side or the "or".

This could be replaced with a "if", like in attached patch, or with a python ternary (x if cond else y), but this is python 2.5+.

Original link: http://code.google.com/p/dojango/issues/detail?id=55