Fix Object Type Detection to Not Incorrectly Convert Booleans and 0 Integers to None

Prior to this patch, zero integers and False booleans were being converted to None since both evaluate the origin if statement (it not obj) to True.

Signed-off-by: George Sibble <gsibble@gmail.com>
This commit is contained in:
George Sibble 2013-03-07 12:43:46 -06:00
parent a9e0635d31
commit d7e93cbda9
2 changed files with 2 additions and 2 deletions

View File

@ -98,7 +98,7 @@ class ApiClient:
def sanitizeForSerialization(self, obj):
"""Dump an object into JSON for POSTing."""
if not obj:
if type(obj) == type(None):
return None
elif type(obj) in [str, int, long, float, bool]:
return obj

View File

@ -102,7 +102,7 @@ class ApiClient:
def sanitizeForSerialization(self, obj):
"""Dump an object into JSON for POSTing."""
if not obj:
if type(obj) == type(None):
return None
elif type(obj) in [str, int, float, bool]:
return obj