Outils personnels
Vous êtes ici : Accueil 2010 Février 26 Python and oldies or ValueError: year=1876 is before 1900; the datetime strftime() methods require year >= 1900
HADOPI - Le Net en France : black-out

Python and oldies or ValueError: year=1876 is before 1900; the datetime strftime() methods require year >= 1900

by kiorky — last modified 26/02/2010 17:40
Classé sous :

Calling strftime on a date/datetime instance on py24/py26 will raise a value error like this:

>>> from datetime import date
>>> date(1800,1,1).strftime('%d%m%Y')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: year=1800 is before 1900; the datetime strftime() methods require year >= 1900

Quite annoying heh ?

There is a bug related on the python bugtracker here : http://bugs.python.org/issue1777412

 

The work here was to integrate the working patch in the bugreport to py24 and py26 python packages which are in minitage.

So now, with minitage's pythons, you can work with very old dates by default !!!

Just issue:

virtualenv --no-site-packages --distribute minitage
source minitage/bin/activate
minimerge -s
minimerge -v python-2.6 (or 2.4)

And you can use the following interpreter which support those old ages:

minitage/python-2.6/parts/part/bin/python

 

And of course the related patch does not break anything:

$ svn info
URL : http://svn.python.org/projects/python/branches/release24-maint
Révision : 75208
$../parts/part/bin/python Lib/test/test_datetime.py
...
----------------------------------------------------------------------
Ran 230 tests in 0.858s
OK


$ pwd
/home/kiorky/minitage/dependencies/python-2.6/Python-2.6.4
$../parts/part/bin/python Lib/test/test_datetime.py
...
----------------------------------------------------------------------
Ran 245 tests in 0.791s
OK

 

Actions sur le document