[Python-Dev] xmlrpclib and dates before 1900

Guido van Rossum guido at python.org
Thu Apr 3 05:52:52 CEST 2008


On Wed, Apr 2, 2008 at 8:36 PM,  <skip at pobox.com> wrote:
>     Ralf> anyone care to take a look at:
>     Ralf> http://bugs.python.org/issue2014
>     Ralf> It's about xmlrpclib not being able to send datetime objects with
>     Ralf> dates before 1900.
>
>  It's actually not xmlrpclib which has the limitation, but
>  datetime.strftime().  That's a known limitation.  Here's the comment in the
>  datetime code:
>
>         /* Give up if the year is before 1900.
>          * Python strftime() plays games with the year, and different
>          * games depending on whether envar PYTHON2K is set.  This makes
>          * years before 1900 a nightmare, even if the platform strftime
>          * supports them (and not all do).
>          * We could get a lot farther here by avoiding Python's strftime
>          * wrapper and calling the C strftime() directly, but that isn't
>          * an option in the Python implementation of this module.
>          */
>
>  That, in turn, calls time.strftime() which calls the underlying system's
>  strftime() library function.
>
>  Personally, I don't think patching xmlrpclib is the right place to "fix"
>  this problem.  It's possible that the datetime comment is no longer correct
>  and that limitation should be reconsidered.  I see no other mention of
>  PYTHON2K in any .c, .h or .py files in the trunk.

I'd like to see this fixed if possible, but I'm not sure how -- the C
level 'struct tm' has (year - 1900) in the tm_year member, and I'm not
sure that implementations are required to do anything with negative
values there. We'd have to reimplement all of strftime ourselves. I'm
not against that, but there are higher priorities.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list