Skip to content

Commit eaf097e

Browse files
Capture struct.error exceptions on value encoding (#33)
1 parent 0c8a6d4 commit eaf097e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

redisgraph_bulk_loader/entity_file.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def typed_prop_to_binary(prop_val, prop_type):
4848
try:
4949
numeric_prop = int(prop_val)
5050
return struct.pack(format_str + "q", Type.LONG.value, numeric_prop)
51-
except ValueError:
51+
except (ValueError, struct.error):
5252
# TODO ugly, rethink
5353
if prop_type == Type.LONG:
5454
raise SchemaError("Could not parse '%s' as a long" % prop_val)
@@ -58,7 +58,7 @@ def typed_prop_to_binary(prop_val, prop_type):
5858
numeric_prop = float(prop_val)
5959
if not math.isnan(numeric_prop) and not math.isinf(numeric_prop): # Don't accept non-finite values.
6060
return struct.pack(format_str + "d", Type.DOUBLE.value, numeric_prop)
61-
except ValueError:
61+
except (ValueError, struct.error):
6262
# TODO ugly, rethink
6363
if prop_type == Type.DOUBLE:
6464
raise SchemaError("Could not parse '%s' as a double" % prop_val)
@@ -97,15 +97,15 @@ def inferred_prop_to_binary(prop_val):
9797
try:
9898
numeric_prop = int(prop_val)
9999
return struct.pack(format_str + "q", Type.LONG.value, numeric_prop)
100-
except ValueError:
100+
except (ValueError, struct.error):
101101
pass
102102

103103
# Try to parse value as a float.
104104
try:
105105
numeric_prop = float(prop_val)
106106
if not math.isnan(numeric_prop) and not math.isinf(numeric_prop): # Don't accept non-finite values.
107107
return struct.pack(format_str + "d", Type.DOUBLE.value, numeric_prop)
108-
except ValueError:
108+
except (ValueError, struct.error):
109109
pass
110110

111111
# If field is 'false' or 'true', it is a boolean.

0 commit comments

Comments
 (0)