This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Remove time.accept2dyear
Type: enhancement Stage: resolved
Components: Extension Modules, Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: belopolsky, python-dev, vstinner
Priority: normal Keywords: patch

Created on 2011-04-26 19:37 by belopolsky, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
remove-accept2dyear.diff belopolsky, 2011-04-26 19:37 review
datetime_y2k.patch vstinner, 2011-04-26 23:30 review
Messages (13)
msg134493 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2011-04-26 19:37
As implemented in issue 10827, use of 2-digits years in timetuples to mean 4-digit years straddling year 2000 is deprecated in 3.3.  There is no mechanism for issuing deprecation warning for access to a module variable, but a deprecation note was added to its documentation.

Attached patch removes time.accept2dyear and the associated behaviors.
msg134507 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-04-26 22:09
time.rst:

* **Year 2000 (Y2K) issues**: Python depends on the platform's C library, which
  generally doesn't have year 2000 issues, since all dates and times are
  represented internally as seconds since the epoch.  Function :func:`strptime`
  can parse 2-digit years when given ``%y`` format code.  When 2-digit years are
  parsed, they are converted according to the POSIX and ISO C standards: values
  69--99 are mapped to 1969--1999, and values 0--68 are mapped to 2000--2068.

.. class:: struct_time (...) A year value will be handled as described under :ref:`Year 2000 (Y2K) issues <time-y2kissues>` above.

.. [#] The use of ``%Z`` is now deprecated, but the ``%z`` escape that expands to the
   preferred  hour/minute offset is not supported by all ANSI C libraries. Also, a
   strict reading of the original 1982 :rfc:`822` standard calls for a two-digit
   year (%y rather than %Y), but practice moved to 4-digit years long before the
   year 2000.  The 4-digit year has been mandated by :rfc:`2822`, which obsoletes
   :rfc:`822`.

Are these 3 notes still valid? It looks like struct_time note is wrong: the year 70 is now 70 and not interpreted as 1970 anymore.

---

timemodule.c:

PyDoc_STRVAR(module_doc,
"...
The tuple items are:\n\
  year (four digits, e.g. 1998)\n\
...")

=> That's wrong. Example: time.gmtime(-55582200000).tm_year gives 208.

---

/home/haypo/prog/HG/cpython/Modules/timemodule.c: In function 'PyInit_time':
/home/haypo/prog/HG/cpython/Modules/timemodule.c:872: warning: unused variable 'p'
msg134508 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2011-04-26 22:13
On Tue, Apr 26, 2011 at 6:09 PM, STINNER Victor <report@bugs.python.org> wrote:
> It looks like struct_time note is wrong: the year 70 is now 70 and not interpreted as 1970 anymore.

What makes you say so?

1970
msg134509 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2011-04-26 22:20
On Tue, Apr 26, 2011 at 6:09 PM, STINNER Victor <report@bugs.python.org> wrote:
..
>
> timemodule.c:
>
> PyDoc_STRVAR(module_doc,
> "...
> The tuple items are:\n\
>  year (four digits, e.g. 1998)\n\
> ...")
>
> => That's wrong. Example: time.gmtime(-55582200000).tm_year gives 208.

This is wrong regardless of this patch.   I don't mind fixing this,
but it would be a different issue.  Can you suggest a change?  I would
like the docstring to still inform the user that 1998 should be given
as 1998 and not as 98.  Maybe s/four/all/?
msg134512 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-04-26 22:30
"What makes you say so?

1970"

Don't write ">>> " using the email interface :-)

--


>>> t
time.struct_time(tm_year=70, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=1, tm_isdst=0)
>>> time.mktime(t)
-59958144561.0
>>> time.localtime(_)
time.struct_time(tm_year=70, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=2, tm_yday=1, tm_isdst=0)

Year 70 is considered as the year 70.
msg134516 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2011-04-26 22:42
On Tue, Apr 26, 2011 at 6:30 PM, STINNER Victor <report@bugs.python.org> wrote:
>
> STINNER Victor <victor.stinner@haypocalc.com> added the comment:
>
> "What makes you say so?
>
> 1970"
>
> Don't write ">>> " using the email interface :-)
>

Sorry.  That was the output of time.strptime('70', '%y')[0].
msg134517 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2011-04-26 22:52
On Tue, Apr 26, 2011 at 6:09 PM, STINNER Victor <report@bugs.python.org> wrote:
..
> .. class:: struct_time (...) A year value will be handled as described under :ref:`Year 2000 (Y2K) issues <time-y2kissues>` above.

This one needs to be removed.  Thanks.
msg134520 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-04-26 23:30
The next step is to update the datetime module: something like the attached patch (datetime_y2k.patch).
msg134933 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-05-01 22:04
Le mardi 26 avril 2011 à 22:20 +0000, Alexander Belopolsky a écrit :
> Alexander Belopolsky <belopolsky@users.sourceforge.net> added the comment:
> 
> On Tue, Apr 26, 2011 at 6:09 PM, STINNER Victor <report@bugs.python.org> wrote:
> ..
> >
> > timemodule.c:
> >
> > PyDoc_STRVAR(module_doc,
> > "...
> > The tuple items are:\n\
> >  year (four digits, e.g. 1998)\n\
> > ...")
> >
> > => That's wrong. Example: time.gmtime(-55582200000).tm_year gives 208.
> 
> This is wrong regardless of this patch.   I don't mind fixing this,
> but it would be a different issue.  Can you suggest a change?  I would
> like the docstring to still inform the user that 1998 should be given
> as 1998 and not as 98.  Maybe s/four/all/?

"year (e.g. 1998)\n" is enough.
msg134988 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-05-02 16:31
New changeset e6f6ac8c2502 by Alexander Belopolsky in branch 'default':
Issue #11930: Remove deprecated time.accept2dyear.
http://hg.python.org/cpython/rev/e6f6ac8c2502
msg134993 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-05-02 17:14
New changeset db2ac3dc6cc2 by Alexander Belopolsky in branch 'default':
Issue #11930: Remove year >= 1000 limitation from datetime.strftime.
http://hg.python.org/cpython/rev/db2ac3dc6cc2
msg134996 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-05-02 18:15
New changeset bfd741162741 by Alexander Belopolsky in branch 'default':
Issue #11930: Added Misc/NEWS and versionchanged entries.
http://hg.python.org/cpython/rev/bfd741162741
msg135008 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-05-02 21:04
> New changeset e6f6ac8c2502 by Alexander Belopolsky in branch 'default':
> Issue #11930: Remove deprecated time.accept2dyear.

Great!
History
Date User Action Args
2022-04-11 14:57:16adminsetgithub: 56139
2011-05-02 21:04:16vstinnersetmessages: + msg135008
2011-05-02 18:15:13python-devsetmessages: + msg134996
2011-05-02 17:17:26belopolskysetstatus: open -> closed
resolution: accepted
components: + Extension Modules, Library (Lib)
stage: patch review -> resolved
2011-05-02 17:14:48python-devsetmessages: + msg134993
2011-05-02 16:31:47python-devsetnosy: + python-dev
messages: + msg134988
2011-05-01 22:04:17vstinnersetmessages: + msg134933
2011-04-26 23:30:06vstinnersetfiles: + datetime_y2k.patch

messages: + msg134520
2011-04-26 22:52:18belopolskysetmessages: + msg134517
2011-04-26 22:42:31belopolskysetmessages: + msg134516
2011-04-26 22:30:23vstinnersetmessages: + msg134512
2011-04-26 22:20:56belopolskysetmessages: + msg134509
2011-04-26 22:13:34belopolskysetmessages: + msg134508
2011-04-26 22:09:22vstinnersetmessages: + msg134507
2011-04-26 19:37:41belopolskycreate