Skip to content

Commit f962c9d

Browse files
Beuckripken
authored andcommitted
expand_byte_size_suffixes: clearer error message (#6772)
1 parent 3ab3182 commit f962c9d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tools/shared.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,10 @@ def expand_response(data):
11151115
# Given a string with arithmetic and/or KB/MB size suffixes, such as "1024*1024" or "32MB", computes how many bytes that is and returns it as an integer.
11161116
def expand_byte_size_suffixes(value):
11171117
value = value.lower().replace('tb', '*1024*1024*1024*1024').replace('gb', '*1024*1024*1024').replace('mb', '*1024*1024').replace('kb', '*1024').replace('b', '')
1118-
return eval(value)
1118+
try:
1119+
return eval(value)
1120+
except:
1121+
raise Exception("Invalid byte size, valid suffixes: KB, MB, GB, TB")
11191122

11201123
# Settings. A global singleton. Not pretty, but nicer than passing |, settings| everywhere
11211124

0 commit comments

Comments
 (0)