Adds type error for handling NoneType exceptions

This commit is contained in:
Mirko Galimberti
2018-07-27 12:03:39 +02:00
parent a22aac1e65
commit a053df7b75
+3 -2
View File
@@ -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