summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gerber/utils.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/gerber/utils.py b/gerber/utils.py
index 0f0c07c..64cd6ed 100644
--- a/gerber/utils.py
+++ b/gerber/utils.py
@@ -140,12 +140,15 @@ def write_gerber_value(value, format=(2, 5), zero_suppression='trailing'):
# Suppression...
if zero_suppression == 'trailing':
- while digits[-1] == '0':
+ while digits and digits[-1] == '0':
digits.pop()
else:
- while digits[0] == '0':
+ while digits and digits[0] == '0':
digits.pop(0)
+ if not digits:
+ return '0'
+
return ''.join(digits) if not negative else ''.join(['-'] + digits)