[Python-Dev] Checking input range in time.asctime and time.ctime

Alexander Belopolsky alexander.belopolsky at gmail.com
Wed Jan 5 18:33:55 CET 2011


On Mon, Jan 3, 2011 at 7:47 PM, Guido van Rossum <guido at python.org> wrote:
> Given the rule garbage in -> garbage out, I'd do the most useful
> thing, which would be to produce a longer output string (and update
> the docs). This would match the behavior of e.g. '%04d' % y when y >
> 9999. If that means the platform libc asctime/ctime can't be used, too
> bad.

I've committed code that does not use platform libc asctime/ctime
anymore.  Now it seems odd that we support years > 9999 but not years
< 1900.  A commonly given explanation for rejecting years < 1900 is
that Python has to support POSIX standard for 2-digit years.  However,
this support is conditional on the value of time.accept2dyear and
several people argued that when it is set to false, full range of
years should be supported.  Furthermore, in order to support 2-digit
years, there is no need to reject years < 1900.  It may be confusing
to map 99 to 1999 while accepting 100 as is, but I don't see much of
the problem in accepting 4-digit years from 1000 through 1899 while
mapping [0 - 99] to present times according to POSIX standard.

See http://bugs.python.org/issue10827 for more.


More information about the Python-Dev mailing list