From 8d751ecc9beca1a328f0e52a52325ea9d7d8c559 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 17 Feb 2014 18:36:29 +0100 Subject: [PATCH] valid port type before compare to min and max value --- tiramisu/option.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tiramisu/option.py b/tiramisu/option.py index af7a67a..d46c8c9 100644 --- a/tiramisu/option.py +++ b/tiramisu/option.py @@ -852,12 +852,13 @@ class PortOption(Option): for val in value: try: - if not self._min_value <= int(val) <= self._max_value: - raise ValueError(_('invalid port, must be an between {0} ' - 'and {1}').format(self._min_value, - self._max_value)) + int(val) except ValueError: raise ValueError(_('invalid port')) + if not self._min_value <= int(val) <= self._max_value: + raise ValueError(_('invalid port, must be an between {0} ' + 'and {1}').format(self._min_value, + self._max_value)) class NetworkOption(Option):