+ # Sanity check the integer "timeout" parameter. We want to
+ # bail if either the given parameter is not an integer, or if
+ # it's negative. To handle both at the same time, we try to
+ # parse an integer...
+ timeout = s.get('timeout', 300)
+ try:
+ self.timeout = int(timeout)
+ except:
+ # ...and set self.timeout to a negative value if we can't...
+ self.timeout = -1
+
+ # Now we check to see if the timeout value is negative. That
+ # will happen if it was either negative to begin with, or
+ # non-integer (and we set it negative).
+ if self.timeout < 0:
+ msg = 'Invalid value "' + timeout + '" for timeout '
+ msg += 'in section "' + s.name + '"'
+ raise configparser.ParsingError(msg)
+