Permalink
Browse files

Prohibit +/-infinity as timeout values

  • Loading branch information...
1 parent 1da312e commit 28a7ed9a93b696409889ff50fc901f03028183c6 @ajdavis ajdavis committed Oct 6, 2012
Showing with 3 additions and 1 deletion.
  1. +1 −1 pymongo/common.py
  2. +2 −0 test/test_uri_parser.py
View
@@ -93,7 +93,7 @@ def validate_positive_float(option, value):
value = float(value)
except (ValueError, TypeError):
raise err
- if value <= 0:
+ if not 0 < value < float('inf'):
raise err
return value
View
@@ -84,6 +84,8 @@ def test_split_options(self):
self.assertRaises(ConfigurationError, split_options, 'socketTimeoutMS=0.0')
self.assertRaises(ConfigurationError, split_options, 'connectTimeoutMS=foo')
self.assertRaises(ConfigurationError, split_options, 'connectTimeoutMS=0.0')
+ self.assertRaises(ConfigurationError, split_options, 'connectTimeoutMS=inf')
+ self.assertRaises(ConfigurationError, split_options, 'connectTimeoutMS=-inf')
self.assertTrue(split_options('socketTimeoutMS=300'))
self.assertTrue(split_options('connectTimeoutMS=300'))
self.assertEqual({'sockettimeoutms': 0.3}, split_options('socketTimeoutMS=300'))

0 comments on commit 28a7ed9

Please sign in to comment.