#110 DateConverter errors with month name

closed-fixed
nobody
None
5
2011-09-24
2010-12-11
Anonymous
No

formencode.validators.py : line 1959 should be "except (TypeError, ValueError):" instead of "except TypeError:"

Example:
------------------------------------------------------
d = DateConverter()
print d.to_python('12/Dec/2010')

Traceback (most recent call last):
File "D:\dev\py\test.py", line 47, in <module>
print d.to_python('12/Dec/2010')
File "C:\Python26\lib\site-packages\formencode-1.2.3dev-py2.6.egg\formencode\api.py", line 413, in to_python
value = tp(value, state)
File "C:\Python26\lib\site-packages\formencode-1.2.3dev-py2.6.egg\formencode\validators.py", line 1945, in _to_python
return self.convert_day(value, state)
File "C:\Python26\lib\site-packages\formencode-1.2.3dev-py2.6.egg\formencode\validators.py", line 1958, in convert_day
month = int(match.group(2))
ValueError: invalid literal for int() with base 10: 'Dec'

With patch applied:

d = DateConverter()
print d.to_python('12/Dec/2010')
>> 2010-12-12

Discussion

  • Working on this right now.

     
  • Found that I fixed this already in <<changeset a468dca5e51f>>.

    Added a unit test and fixed other bugs detected by that test in <<changeset 1f52da3fafa8>>.

     
    • status: open --> closed-fixed