[issue10563] Spurious newline in time.ctime

Eric Smith report at bugs.python.org
Sun Nov 28 17:09:31 CET 2010

Eric Smith <eric at trueblade.com> added the comment:

There's an error in time_ctime where it expects the length of the string to be fixed:

    if (p[24] == '\n')
        p[24] = '\0';

It doesn't count on the year having 5 digits. It should probably say (untested):
    l = len(p);
    if (l > 0 && p[l-1] == '\n')
        p[l-1] = '\0';

I'll whip up a patch and some tests. I'm not sure if the tests will work on platforms other than Linux. I'll see what I can find out about ctime and large values.

nosy: +eric.smith

Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list