Author: ianb
Date: 2008-11-14 16:36:32 -0700 (Fri, 14 Nov 2008)
New Revision: 3657
Modified:
FormEncode/trunk/docs/news.txt
FormEncode/trunk/formencode/validators.py
Log:
Fix some URL doctests (which were requesting some bad sites). Also i-name
test. Lastly fix Number.to_python('infinity'), which failed because you can't
convert that float value to an integer (SF 2213051)
Modified: FormEncode/trunk/docs/news.txt
===================================================================
--- FormEncode/trunk/docs/news.txt 2008-11-14 23:25:49 UTC (rev 3656)
+++ FormEncode/trunk/docs/news.txt 2008-11-14 23:36:32 UTC (rev 3657)
@@ -19,6 +19,9 @@
all missing keys as the empty string (previously the first key was
required and would raise KeyError).
+* :class:`formencode.validators.Number` works with ``inf`` float
+ values (before it would raise a OverflowError).
+
1.1
---
Modified: FormEncode/trunk/formencode/validators.py
===================================================================
--- FormEncode/trunk/formencode/validators.py 2008-11-14 23:25:49 UTC (rev
3656)
+++ FormEncode/trunk/formencode/validators.py 2008-11-14 23:36:32 UTC (rev
3657)
@@ -1002,6 +1002,8 @@
Traceback (most recent call last):
...
Invalid: Please enter a number that is 10.5 or smaller
+ >>> Number().to_python('infinity')
+ inf
"""
@@ -1012,8 +1014,12 @@
def _to_python(self, value, state):
try:
value = float(value)
- if value == int(value):
- return int(value)
+ try:
+ int_value = int(value)
+ except OverflowError:
+ int_value = None
+ if value == int_value:
+ return int_value
return value
except ValueError:
raise Invalid(self.message('number', state),
@@ -1411,11 +1417,11 @@
Traceback (most recent call last):
...
Invalid: You must start your URL with http://, https://, etc
- >>> u.to_python('http://colorstudy.com/doesnotexist.html')
+ >>> u.to_python('http://ianbicking.org/doesnotexist.html')
Traceback (most recent call last):
...
Invalid: The server responded that the page could not be found
- >>>
u.to_python('http://this.domain.does.not.exists.formencode.org/test.html')
+ >>>
u.to_python('http://this.domain.does.not.exist.example.org/test.html')
Traceback (most recent call last):
...
Invalid: An error occured when trying to connect to the server: ...
@@ -1554,7 +1560,7 @@
>>> inames.to_python("=John Smith")
Traceback (most recent call last):
...
- formencode.api.Invalid: "John Smith" is an invalid i-name
+ Invalid: "John Smith" is an invalid i-name
>>> inumbers = XRI(xri_type="i-number")
>>> inumbers.to_python("!!1000!de21.4536.2cb2.8074")
'!!1000!de21.4536.2cb2.8074'
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
FormEncode-CVS mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/formencode-cvs