Would be possible to use regexp instead?
Fixing this error from tests:
======================================================================
ERROR: testFailFromText2 (test_grange.GRangeTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "~/dnspython/tests/test_grange.py", line 81, in testFailFromText2
self.assertRaises(dns.exception.SyntaxError, bad)
File "/usr/lib64/python2.7/unittest/case.py", line 511, in assertRaises
callableObj(*args, **kwargs)
File "~/dnspython/tests/test_grange.py", line 80, in bad
dns.grange.from_text('%s-%d/%d' % (start, stop, step))
File "~/dnspython/dns/grange.py", line 39, in from_text
start = int(cur)
ValueError: invalid literal for int() with base 10: ''
state = 0
# state 0 1 2 3 4
# x - y / z
+
+ if text and text[0] == '-':
+ raise dns.exception.SyntaxError("Start cannot be a negative number")
+
for c in text:
if c == '-' and state == 0:
start = int(cur)
raise dns.exception.SyntaxError("Could not parse %s" % (c))
if state in (1, 3):
- raise dns.exception.SyntaxError
+ raise dns.exception.SyntaxError()
if state == 2:
stop = int(cur)