Adds type error for handling NoneType exceptions
This commit is contained in:
+3
-2
@@ -103,17 +103,18 @@ class CacheRepresenter(object):
|
|||||||
cache[field][value] = nvalue
|
cache[field][value] = nvalue
|
||||||
return nvalue
|
return nvalue
|
||||||
|
|
||||||
|
|
||||||
def safe_int(x, i=0):
|
def safe_int(x, i=0):
|
||||||
try:
|
try:
|
||||||
return int(x)
|
return int(x)
|
||||||
except ValueError:
|
except (ValueError, TypeError):
|
||||||
return i
|
return i
|
||||||
|
|
||||||
|
|
||||||
def safe_float(x):
|
def safe_float(x):
|
||||||
try:
|
try:
|
||||||
return float(x)
|
return float(x)
|
||||||
except ValueError:
|
except (ValueError, TypeError):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user